Have you ever wondered how to iterate a set number of times in XSL? While it is easy to "walk" a nodelist using xsl:for-each or xsl:template, it is a bit more tricky to iterate a set number of times (the "for" statement in C#). Here is what you do:
<?xml version="1.0"?><xsl:stylesheet version="1.0" xmlns:xsl="..."><xsl:template match="/"> <xsl:call-template name="iterator"> <xsl:with-param name="LastNo">10</xsl:with-param> </xsl:call-template></xsl:template><xsl:template name="iterator"> <xsl:param name="LastNo"/> <xsl:param name="i" select="0"/> <xsl:value-of select="$i"/> <xsl:if test="$i < $LastNo"> <xsl:call-template name="iterator"> <xsl:with-param name="LastNo" select="$LastNo"/> <xsl:with-param name="i" select="$i + 1"/> </xsl:call-template> </xsl:if></xsl:template></xsl:stylesheet>
This will iterate through the "iterator" template 10 (derived from the "LastNo" variable) times.
SWEET! tanks. very helpful.
Wonderfulllllll :)