Re: [xml-dev] Variables in XSL!

From
Jeff Rafter <>
To
Peter Thornqvist <>,
Date
2001-11-27T20:23:21Z
ID
<005501c17781$5c17ba70$5a171318@C1980223A>
Thread
Re: [xml-dev] Variables in XSL!
Peter,

> Is it possible to have variables/counters
> in XSL, like in vbscript: i=i+1 etc?.

Not like that, no. You can assign values to "variables" but then you cannot
change the value once you have set it (in the current scope).

> I would like to keep track of when the 10th value comes and then
> do a line break...

Something like this will do the trick.

<xsl:for-each select="/MyElements">
  <xsl:if test="position()=10">
    <br />
  </xsl:if>
</xsl:for-each>

In order to actually maintain variables you have to convert the template to
operate recursively and then you can use the output.

HTH,
Jeff Rafter
Defined Systems
http://www.defined.net
XML Development and Developer Web Hosting