我有以下 xml:
<Data>
<Product>
<attribute>
<name>NUMMER</name>
<actionType>RM</actionType>
<actionReason>DISCN</actionReason>
<value>0</value>
</attribute>
<attribute>
<name>NUMMER</name>
<actionType>RM</actionType>
<actionReason>DISCN</actionReason>
<value>12345</value>
</attribute>
<attribute>
<name>RETURN</name>
<actionType>RM</actionType>
<actionReason>DISCN</actionReason>
<value>00</value>
<valueDescription>NO</valueDescription>
</attribute>
<attribute>
<name>ADRESS</name>
<actionType>RM</actionType>
<actionReason>DISCN</actionReason>
<value>4</value>
<valueDescription>ABC</valueDescription>
</attribute>
</Product>
</Data>
我需要编写一个检查,检查属性/名称 = 'NUMMER' 且属性/值 != 0。 我尝试了以下方法但没有效果:
<xsl:if test="Data/product/attribute[name='NUMMER' and value!='0']">
<xsl:if test="Data/product/attribute[name='NUMMER' and not(value='0')]">
请帮忙。 预期输出将仅获取以下属性:
<attribute>
<name>NUMMER</name>
<actionType>RM</actionType>
<actionReason>DISCN</actionReason>
<value>12345</value>
</attribute>
尝试类似:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/Data">
<result>
<xsl:copy-of select="Product/attribute[name='NUMMER' and number(value) ne 0]"/>
</result>
</xsl:template>
</xsl:stylesheet>