XSL "variables" are actually constants - you cannot change their value. It:
<xsl:value-of select="$counter + 1"/>
just print the value of $counter+1
To execute loops you need to use recursion - for example:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template name="loop"> <xsl:param name="i"/> <xsl:param name="limit"/> <xsl:if test="$i <= $limit"> <div> <xsl:value-of select="$i"/> </div> <xsl:call-template name="loop"> <xsl:with-param name="i" select="$i+1"/> <xsl:with-param name="limit" select="$limit"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template match="/"> <html> <body> <xsl:call-template name="loop"> <xsl:with-param name="i" select="0"/> <xsl:with-param name="limit" select="10"/> </xsl:call-template> </body> </html> </xsl:template> </xsl:stylesheet>
although itβs better to try to avoid loops - in most cases, XSL can be written to avoid this, but I donβt understand what you are trying to achieve to give you a complete solution.
source share