wood burning stoves 2.0*
The moose likes XML and Related Technologies and the fly likes How to increment a value in xsl? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How to increment a value in xsl?" Watch "How to increment a value in xsl?" New topic
Author

How to increment a value in xsl?

Viswanathan Ramasamy
Greenhorn

Joined: Nov 14, 2005
Posts: 23
hi all,

I want to increment a valu in xsl.
Code :

1 <xsl:variable name="uniqueID_Address1" select="'0'"/>
2 <xsl:for-each select="Z">
3 <xsl:if test="@n=$uniqueID">
4<xsl:value-of select="$uniqueID_Address1=$uniqueID_Address1+1"/>
5 </xsl:if>

I'm getting false in line no 4.


With Regards<br />Viswa
Aryan Khan
Ranch Hand

Joined: Sep 12, 2004
Posts: 290

Viswanathan,

You can not change the variable value in XSL not like the other languages.

Try using recursion

Regards
Ahmad


OCP/MCP/SCJP/SCWCD/IBM XML/SCMAD/SCEA-1
Aryan Khan
Ranch Hand

Joined: Sep 12, 2004
Posts: 290

Viswanathan,

You can not change the variable value in XSL not like the other languages.

Try using recursion

Regards
Ahmad
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

XSLT is not a procedural language like Java, it is a functional language. And it has a lot of functions (courtesy of XPath) that allow you to write it that way. So something like:is the replacement for those 5 lines.
 
 
subject: How to increment a value in xsl?
 
Similar Threads
xsl looping
need to generate some numbers using loop, the number of times condition met
need to generate some numbers using loop, the number of times condition met
how to use variable in XSLT if condition
XSLT equality test