Condition works for XSLT 1.0 stylesheet, but not for XSLT 2.0 stylesheet

Consider this condition that exists in a template that is called recursively:

<xsl:if test="$i &lt;= $count">

      

I am using XSLT 2.0 processor (Saxon-B 9.1.0.6). The condition only works when using an XSLT 1.0 stylesheet. If the style version is set to 2.0 (as it should), it stops working.

Any ideas why?

Everybody is here:

<xsl:template name="for.loop">
    <xsl:param name="i" />
    <xsl:param name="count" />

    <xsl:if test="$i &lt;= $count">
    ...
    </xsl:if>

    <!-- Repeat the loop by recursion -->
    <xsl:if test="$i &lt;= $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.

0


source to share


1 answer


Here's my suspicion: depending on what datatypes $i

and $coun

t, the "less" test may fail in 2.0 (which supports more datatypes than 1.0), where there is an implicit conversion in 1.0 that does the right thing.



Try converting the data to the type you want before comparing it eg. using number()

.

+1


source







All Articles