On Thu, Jul 07, 2005 at 03:25:03PM +0200, Vlastimil Krejcir wrote: > 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">A</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.
use http://www.exslt.org/str/functions/tokenize/index.html EXSLT - str:tokenize to generate a node set for each letter embedded as a string in the stylesheet for example, then apply the template to each node in the nodeset. Daniel -- Daniel Veillard | Red Hat Desktop team http://redhat.com/ [EMAIL PROTECTED] | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/ _______________________________________________ xslt mailing list, project page http://xmlsoft.org/XSLT/ [email protected] http://mail.gnome.org/mailman/listinfo/xslt
