Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml xsl:if test=没有匹配的元素?_Xml_Xslt - Fatal编程技术网

Xml xsl:if test=没有匹配的元素?

Xml xsl:if test=没有匹配的元素?,xml,xslt,Xml,Xslt,给定这样的XML <data> <item temp="cool"/> <item temp="hot"/> <item temp="hot"/> <item temp="lukewarm"/> </data> 我可以轻松测试任何东西是否热: <xsl:if test="/data/item/@temp = 'hot'"> Something's hot in her

给定这样的XML

<data>
    <item temp="cool"/>
    <item temp="hot"/>
    <item temp="hot"/>
    <item temp="lukewarm"/>
</data>

我可以轻松测试任何东西是否热:

<xsl:if test="/data/item/@temp = 'hot'">
    Something's hot in here
</xsl:if>

这里有点热
但是,如果没有什么是热的,对我来说测试有点复杂:

<xsl:choose>
    <xsl:when test="/data/item/@temp = 'hot'"></xsl:when>
    <xsl:otherwise>
        Nothing's hot in here.
    </xsl:otherwise>
</xsl:choose>

这里没什么热的。
我有几种情况,我只想在not情况下附加一些元素,所以我想消除额外的代码

我是否可以将其写入一个测试语句

顺便说一句,这不起作用

<xsl:if test="/data/item/@temp != 'hot'">
    Nothing's hot in here
</xsl:if>

这里没什么热的

因为只要有一个东西不是热的,它就会传递。

尝试使用XPath:
not(/data/item[@temp='hot'])


这将转换为
,其中不存在具有值为“hot”的“temp”属性的=用于比较值<代码>非()
用于节点集。