Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

xsl:param or xsl:variable gets reset.

843834Oct 11 2001 — edited Oct 11 2001
Hi, I'm trying to keep a counter using a top level variable in xsl.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="rownumber">1</xsl:variable>

And every time my xsl calls a specific template, i want to keep a counter.

<xsl:template match="row">
<xsl:variable name="rownumber">
<xsl:number value="$rownumber+1"/>
</xsl:variable>
<xsl:variable value="$rownumber"/>
</xsl:template>

However, my variable $rownumber always gets reset to the default value of "1" everytime the template is called and returns a value of "2".
Is there a work around for this? Is there a way to keep a counter in xsl? Can top level variable change?
I don't want to count the nodes either....

Thanks in advanced,
jon


Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 8 2001
Added on Oct 11 2001
3 comments
392 views