XSL is NOT a programming language; rather it is a stylesheet. Native XSL variables are single assignment and done. I have used XML / XSL (and few of its pre-decessors -- SGML anybody) quite extensively and most of the time, with a little creativity, you can achieve whatever you want even with this limitation. If you absolutely must have a counter then there are some external "plug-ins/extensions" (JavaScript-like scripting or Java extension) that you can use to get whatever you need. I usually see a true need to achieve a variable counter via one of those mechanism once in a LONG while.In any case, what is your use case for having a counter?HTH!
I think this post illustrates the significant issues one faces with moving from TPLs to XSLT. Counters are used quite often in templates, you have a list of 10 containers, you want a separator between them but not before the 1st or after the last, thus you need 9. Or you take these 10 containers and put them, odd number in the left column and even in the right again matching that divs and tables are closed properly. All of these are easy in TPLs.
VP have you seen any good docs on IWOV XSLT ? Any way of adding perl ?
...<xsl:apply-templates select="containers"/>...<xsl:template match="containers"> Whatever other content that goes in this container. <xsl:if test="position() != last()"> put your separator here. </xsl:if></xsl:template>NOTE: This will output each container content followed by a separator except for a separator after the last container content.
<table> <xsl:apply-templates select="containers"/></table>...<xsl:template match="containers"> <xsl:choose> <xsl:when test="position() mod 2 = 0"> <td> right column content </td> <xsl:text disable-output-escaping="yes"></tr></xsl:text> </xsl:when> <xsltherwise> <xsl:text disable-output-escaping="yes"><tr></xsl:text> <td> left column content </td> </xsltherwise> </xsl:choose> </xsl:template>
I use # 1 as my primary resource whenever I need to. Link # 2 is like a tech list for posting questions. I haven't posted in a few years now so I am not sure if it is still up and running. Link # 3 covers a lot of the basics and some advanced scenarios as well.HTH!