Consider this condition that exists in a template that is called recursively:
<xsl:if test="$i <= $count">
I’m using an XSLT 2.0 processor (Saxon-B 9.1.0.6). The condition seems to work only when running an XSLT 1.0 stylesheet. When the stylesheet version is set to 2.0 (as it should be), it stops working.
Any ideas why?
Here’s the whole thing:
<xsl:template name="for.loop">
<xsl:param name="i" />
<xsl:param name="count" />
<xsl:if test="$i <= $count">
...
</xsl:if>
<!-- Repeat the loop by recursion -->
<xsl:if test="$i <= $count">
<xsl:call-template name="for.loop">
<xsl:with-param name="i">
<xsl:value-of select="$i + 1" />
</xsl:with-param>
<xsl:with-param name="count">
<xsl:value-of select="$count" />
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>
Thanks.
Here is my suspicion: Depending on what data types
$iand$count are, the “less than” test may fail in 2.0 (which supports more data types than 1.0), where in 1.0 an implicit conversion exists that does the right thing.Try to convert the data to the right type before you compare it, e.g. using
number().