Re: [xsl] For Loop in XSLT

Subject: Re: [xsl] For Loop in XSLT
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 3 May 2002 12:12:46 +0100
Hi Ratul,

> 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.

It depends on what you want to loop over and what you want to do with
the loop. If you want to iterate over a set of nodes, and create part
of the result tree for each, you can use xsl:for-each or
xsl:apply-templates. Certain "aggregator" functions are built in, such
as sum() (to get the sum of a set of nodes) or count() (to count how
many nodes there are in a set). (There are more aggregator functions
in XPath 2.0.) Otherwise, you're right that you have to use a
recursive template.



Jeni Tennison

 XSL-List info and archive:

Current Thread