[英]XPath - Find node that contain at least 3 of 4 conditions is matched in child node
[英]XPath multiple conditions on same child node
我需要根据节点的子节点是否满足所有条件来过滤节点。 这是一个例子:
<root>
<grp pos="1">
<test pos="1" id="2"/>
<test pos="2" id="1"/>
<test pos="3" id="1"/>
<test pos="4" id="2"/>
<test pos="5" id="1"/>
</grp>
<grp pos="2">
<test pos="6" id="1"/>
<test pos="7" id="2"/>
<test pos="8" id="1"/>
<test pos="9" id="1"/>
<test pos="10" id="2"/>
</grp>
</root>
和xsl
<xsl:template match="/root">
<xsl:value-of select="grp[test/@pos='1' and test/@id='1']/@pos"/>
</xsl:template>
对于两种情况,我都需要test
以引用同一节点。 我想要的是不让任何grp
节点通过条件,但是第一个节点通过,因为它有一个孩子通过了第一个条件,另一个通过了第二个。 我希望谓词需要一个同时通过两者的孩子。
好的,我不知道,但看来您可以嵌套谓词:
<xsl:value-of select="grp[test[@pos='1' and @id='1']]/@pos"/>
这就是我想要的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.