XPATH测试具有相同属性的两个元素

时间:2017-10-03 20:32:03

标签: xml xslt xpath xslt-1.0

给出这个xml:

var res = orientation(...);
DoAThing(res.heading);
DoAThing(res.pitch);
DoAThing(res.roll);

<illustratedPartsCatalog> <figure id="fig1">...</figure> <catalogSeqNumber>...</catalogSeqNumber> <figure id="fig2" changeType="delete">...</figure> <catalogSeqNumber>...</catalogSeqNumber> <figure id="fig3" changeType="delete">...</figure> <catalogSeqNumber>...</catalogSeqNumber> <figure id="fig6">...</figure> </illustratedPartsCatalog> 是否可以更紧凑地编写以下XPATH?

illustratedPartsCatalog

例如,我尝试了很多变种,但都失败了:

<xsl:if test="figure/@changeType='delete' or descendant::*/@changeType='delete'">

1 个答案:

答案 0 :(得分:1)

由于figureillustratedPartsCatalog的后代,你可以写这个......

<xsl:if test="descendant::*/@changeType='delete'">

或者更好的是,这......

<xsl:if test=".//*/@changeType='delete'">