Re: [xsl] For Loop in XSLT

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 (grouping) and (tables)

In general, only when you have a case like the one demonstrated in (iteration) 
or when you're needing to walk through a string do you need recursion.

   - Mike
  mike j. brown                   |  xml/xslt:
  denver/boulder, colorado, usa   |  resume:

 XSL-List info and archive:

Current Thread