Re: [xsl] increment variable with xsl:for-each

Subject: Re: [xsl] increment variable with xsl:for-each
From: Brian Chrisman <brian.chrisman@xxxxxx>
Date: Fri, 26 Mar 2004 11:06:17 +0100
Tuan Luu wrote:

hello I'm looking for a code to increment a variable in xsl:for-each loop

I ended up here:

<xsl:variable name="a">1</xsl:variable>

<xsl:for-each select="name">



You may be looking for:
<xsl:variable name="a" select="count(name)"/>
or possibly:
<xsl:for-each select="name">
   <count><xsl:value-of select="position()"/></count>
</xsl:for-each>

The kind of information you are probably looking for when you use $a is probably already provided. If not, use a recursive template as mentioned by several other people here.

<xsl:value of select="{$a+1}"/>
<xsl:value of select="{$a}"/>

</xsl:for-each>


thanks for any answer

Current Thread