Param not incrementing in for-each

Please support our XML, XSLT and XPATH advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2009
Posts: 2
Reputation: RetawGnrips is an unknown quantity at this point 
Solved Threads: 0
RetawGnrips RetawGnrips is offline Offline
Newbie Poster

Param not incrementing in for-each

 
-1
  #1
Aug 5th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 45
Reputation: bcasp is an unknown quantity at this point 
Solved Threads: 10
bcasp bcasp is offline Offline
Light Poster

Re: Param not incrementing in for-each

 
0
  #2
Aug 6th, 2009
I don't think variables in XSL are mutable.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 1
Reputation: dph729 is an unknown quantity at this point 
Solved Threads: 0
dph729 dph729 is offline Offline
Newbie Poster

Re: Param not incrementing in for-each

 
0
  #3
Aug 26th, 2009
Originally Posted by bcasp View Post
I don't think variables in XSL are mutable.
No, they're not. "Variable" is really a misnomer.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 911 | Replies: 2
Thread Tools Search this Thread



Tag cloud for XML, XSLT and XPATH
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC