开发者

is the variable of type string or number

When i do this:

    <xsl:variable name="t">
        <xsl:choose>
            <xsl:when test="1=1">
                <xsl:value-of select="1"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="0"/>
            &开发者_高级运维lt;/xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

is the type of the variable named t string or number?

If it is string doesn't that mean that i could simply:

<xsl:variable name="t">
        <xsl:choose>
            <xsl:when test="1=1">1</xsl:when>
            <xsl:otherwise>0</xsl:otherwise>
        </xsl:choose>
    </xsl:variable>


With XSLT 1.0 the type of your variable is in both cases a result tree fragment containing a text node.


XSLT 1.0 doesn't have strong typing as present in XSLT 2.0.

In XSLT 1.0 a variable with nonempty body is of type RTF (Result Tree Fragment).

In your specific case the variable is an RTF with one text node in it. The string value of the variable (in both cases) happens to be castable as number, and this may be used to reference the variable with XPath operators that expect a numeric argument (and the reference will be substituted with number($t) and this will not be NaN).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜