Altova Mailing List Archives


RE: [xsl] Iteration without nodes

From: "Michael Kay" <mike@------------>
To:
Date: 7/26/2006 4:05:00 PM
> I've successfully used the expression <xsl:for-each
> select="fieldcount[position() &lt; $lastNo]"> to perform a 
> certain operation a number of times.  I'm not sure where I 
> got it and can't find information on why it works.  Now I'm 
> doing a slightly different stylesheet and I can't get the 
> desired result.  Could someone explain how this operation works.

Colin has explained how it works.

In XSLT 2.0 you can do <xsl:for-each select="1 to $N">.

In XSLT 1.0 the purist solution is a recursive template to which you pass a
parameter N indicating the number of iterations required; it does the work
once, then if N>1 it calls itself, passing the value N-1 as the number of
iterations remaining. But the dirty hack of iterating over a
sufficiently-large node-set is often preferable, because you don't risk
running out of stack space.

Michael Kay
http://www.saxonica.com/

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.