xsl:param or xsl:variable gets reset.
843834Oct 11 2001 — edited Oct 11 2001Hi, 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