Hello,

I am currently trying to use the code below to increment the currentChild after every iteration. However, in the output shown below, it is apparent that the value is never changing.

There are four children in this example, so it is printing out the statements the correct number of times, just not incrementing the value.

What can I do to keep track of the currentChild count?

Thanks.

Code:

<xsl:param name="currentChild">0</xsl:param>

<xsl:for-each select="Attribute[./@name='Children.Name']/Value">
   <xsl:value-of select="$currentChild"/> before increment<br/>
   <xsl:with-param name="currentChild" select="$currentChild+1"/>
   <xsl:value-of select="$currentChild"/> after increment<br/>
</xsl:for-each>

Output:
0 before increment
0 after increment
0 before increment
0 after increment
0 before increment
0 after increment
0 before increment
0 after increment

Recommended Answers

All 2 Replies

I don't think variables in XSL are mutable.

I don't think variables in XSL are mutable.

No, they're not. "Variable" is really a misnomer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.