RE: [xsl] Incrementing a Global variable

Subject: RE: [xsl] Incrementing a Global variable
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 27 Aug 2003 18:24:52 +0100
> 
> Though the issue about incrementing the variables has
> been discussed a lot on this list, I feel if there is
> a feature where some sort of variable incrmenting is
> possible in XSLT, it will save lot of programming
> hours producing a trivial thing as generating serial
> nos. I am not suggesting to deviate from the viewpoint
> that XSLT should be a functional language.

But it would deviate from that principle. It would change it from a
functional language to a procedural one, in which instructions have to
be executed in a fixed order.


> Also if we can have looping constructs
> which can iterate over number ranges for e.g.
> 
> for (int i=0; i < n; i++) , it will facilitate
> processing loops in a diffrent way. 

XSLT 2.0 allows you to do this:

<xsl:for-each select="20 to 30">
  <xsl:value-of select="."/>
</xsl:for-each>

You can simulate this in 1.0 with

<xsl:for-each select="//node()[position() &lt;= 10]">
  <xsl:value-of select="position() + 20"/>
</xsl:for-each>

Michael Kay


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


Current Thread