|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: For Loop in XSLT
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








