[xslt] How to generate alphabet using xslt?



  Hello,

I would like to solve some issue about generating alphabet -- exactly I need some cycle goes through every letter in alphabet and generate html code (for example) like this:

<a href="#A">A</a>
<a href="#B">B</a>
...
<a href="#Z">Z</a>

I find there is no classic "for" or "while" loop in xslt. I have used classic recursion way which do the work as good as classic imperative loop. So I can generate numbers from 65 to 96 (which are equivalents to whole alphabet in ASCII). XPath-2.0 defines function codepoints-to-string() which can solve everything = transforming the numbers into a letters. But xsltproc does not follow XPath-2.0 (yet). Do you know some ellegant solution how to do it with XSLT-1.0 and XPath-1.0?

I have found some solutions, but not ellegant I think. The first one is to include the alphapet letters into processed xml document (ugly solution I think). Another one is to use string variable with whole alphabet ($alphabet = "ABCD...Z") and cut one letter in each recursion call (not bad, but still it is like using crutches). And the last solution I have found -- using html coding for letters (&#<number>;) for writing letters and only the numbers for references: <a href="#l65">&#65;</a>

What do you think about? I only beginning with xslt and I am sure there are a lot of tricks for writing ellegant code. But I don't know them.

Thanks for help

Vlastik

-----------------------------------------------------------------------------
Mgr. Vlastimil Krejčíř
Library and Information Centre, Institute of Computer Science
Masaryk University in Brno, Czech Republic
Email: krejcir (at) ics (dot) muni (dot) cz
ICQ: 163963217
-----------------------------------------------------------------------------


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]