943,600 Members | Top Members by Rank

Ad:
Aug 5th, 2009
-1

Param not incrementing in for-each

Expand Post »
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:
XML, XSLT and XPATH Syntax (Toggle Plain Text)
  1. <xsl:param name="currentChild">0</xsl:param>
  2.  
  3. <xsl:for-each select="Attribute[./@name='Children.Name']/Value">
  4. <xsl:value-of select="$currentChild"/> before increment<br/>
  5. <xsl:with-param name="currentChild" select="$currentChild+1"/>
  6. <xsl:value-of select="$currentChild"/> after increment<br/>
  7. </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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
RetawGnrips is offline Offline
2 posts
since Jul 2009
Aug 6th, 2009
0

Re: Param not incrementing in for-each

I don't think variables in XSL are mutable.
Reputation Points: 23
Solved Threads: 10
Light Poster
bcasp is offline Offline
45 posts
since Apr 2008
Aug 26th, 2009
0

Re: Param not incrementing in for-each

Click to Expand / Collapse  Quote originally posted by bcasp ...
I don't think variables in XSL are mutable.
No, they're not. "Variable" is really a misnomer.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dph729 is offline Offline
1 posts
since Aug 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in XML, XSLT and XPATH Forum Timeline: Replacing ampersand and single quote in XSLT
Next Thread in XML, XSLT and XPATH Forum Timeline: Xpath Corelate Parent With Variable number Of Children





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC