我需要列出所有 INST 名称,但前提是“onlyTesters”节点不存在于上述 XML 正文的“inst/idef”部分中。
我知道这很奇怪,但我无法更改收到的 XML。
XML:
<river>
<station num="699">
<inst name="FLU(m)" num="1">
<idef></idef>
</inst>
<inst name="Battery(V)" num="18">
<idef>
<onlyTesters/>
</idef>
</inst>
</station>
<INST name="PLU(mm)" num="0" hasData="1" virtual="0"/>
<INST name="FLU(m)" num="1" hasData="1" virtual="0"/>
<INST name="Q(m3/s)" num="3" hasData="1" virtual="1"/>
<INST name="Battery(V)" num="18" hasData="1" virtual="0"/>
</river>
XSL:
<xsl:template match="/">
<xsl:apply-templates select="//INST[@hasData = 1 and not(//inst[@num=(current()/@num)]/idef/onlyTesters)]/@name"/>
</xsl:template>
<xsl:template match="//INST[@hasData = 1 and not(//inst[@num=(current()/@num)]/idef/onlyTesters)]/@name">
<xsl:value-of select="@name"/>,
</xsl:template>
我没有对手。
这是我期望的结果:
PLU(mm),FLU(m),Q(m3/s)