【问题标题】:How to check the logical equals condtion in XSLT?如何检查 XSLT 中的逻辑等于条件?
【发布时间】:2013-08-13 18:39:18
【问题描述】:

我在 XSLT 中有这个简单的测试

<xsl:if test="isTrue = 'false'">

但我不知道如何在这里执行逻辑等于运算符。我知道&amp;lt;&amp;lt;&amp;gt;&amp;gt; 那么XSLT 的逻辑等于运算符是什么?我试过&amp;eq;&amp;et;===,还是XSLT只能比较数字?

【问题讨论】:

    标签: xslt logical-operators


    【解决方案1】:

    =should work just fine

    例如这个输入Xml

    <xml>
        <SomeElement>1</SomeElement>
        <SomeAttribute attr="true" />
    </xml>
    

    通过这个变换:

    <?xml version="1.0" ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/xml">
            <xsl:if test="SomeElement=1">
                Some Element is 1
            </xsl:if>
            <xsl:if test="SomeAttribute/@attr='true'">
                Some Attribute is true
            </xsl:if>
        </xsl:template>
    </xsl:stylesheet>
    

    返回

    Some Element is 1
    Some Attribute is true
    

    正如预期的那样。可能错误在路径选择器中,而不是在 test 中?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-01
      • 2017-09-29
      • 2011-10-30
      • 1970-01-01
      • 2014-05-22
      相关资源
      最近更新 更多