[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: For Loop in XSLT

Subject: Re: For Loop in XSLT
From: Mike Brown <mike@xxxxxxxx>
Date: Fri, 3 May 2002 11:59:09 -0600 (MDT)
xslt loop counter variable
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.