This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: For Loop in XSLT


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.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]