> Hello,
I want to create m elements in this form:
<element index="n"/>
Where n = 1 2 .. m
Can is do this with an xsl:for loop??
And if so how
For example for m = 4
<xsl:variable name="m" select="4"/>
<xsl:for-each select="1 to m">
<element index="{position()}"/>
</foreach>
Output:
<element index="1"/>
<element index="2"/>
<element index="3"/>
<element index="4"/>
Is this possible with xslt 1.0 ?
That's only possible in version 2.0
In XSLT 1.0, you must use a named attribute approach:
<xsl:call-template name="loop">
<xsl:with-param name="count">4</xsl:with-param>
</xsl:call-template>
<xsl:template name="loop">
<xsl:param name="count"/>
<xsl:param name="iteration">1</xsl:param>
<element index="{$iteration}"/>
<xsl:if test="$iteration < $count">
<xsl:call-template name="loop">
<xsl:with-param name="count" select="$count"/>
<xsl:with-param name="iteration" select="$iteration +1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
regards,
--
Joris Gillis (
http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Ceterum censeo XML omnibus esse utendum