Subject: Re: [xsl] For Loop in XSLT From: Mike Brown <mike@xxxxxxxx> Date: Fri, 3 May 2002 11:59:09 -0600 (MDT) |
Bagchi Ratul wrote: > I was just wondering if there is something like the for loop we have in > other languages. I simulated it by recursively calling a template from > itself. But I was not sure whether it is the only/best method. To supplement what Jeni and Michael said, the use cases where people think they need a for loop with an arbitrary counter variable are, at least half the time (an estimate based on FAQs on this list), not really needing one at all; the problem can sometimes be redefined in terms of careful selection of nodes to process, through the use of xsl:for-each or xsl:apply-templates. The most common case is when you want to divide a data set into pages, producing a series of tables with a maximum number of rows per table. The FAQ offers several examples in http://www.dpawson.co.uk/xsl/sect2/N4486.html (grouping) and http://www.dpawson.co.uk/xsl/sect2/N7450.html (tables) In general, only when you have a case like the one demonstrated in http://www.dpawson.co.uk/xsl/sect2/N4806.html (iteration) or when you're needing to walk through a string do you need recursion. - Mike ____________________________________________________________________________ mike j. brown | xml/xslt: http://skew.org/xml/ denver/boulder, colorado, usa | resume: http://skew.org/~mike/resume/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] For Loop in XSLT, Michael Kay | Thread | [xsl] Randomizing a node-list -- lo, Dimitre Novatchev |
Re: [xsl] XPath question, Joseph Brightly | Date | RE: [xsl] passing intermediate resu, paul morgan |
Month |