我的xml:如何获得的祖先轴的属性在XSLT
<msg id="abc" type="test">
<local id="def"/>
<cnts x:type="fld" id="111" type="a2">
</cnts>
</msg>
的XSLT是:
<xsl:template match="contents[@x:type='fld']">
<xsl:variable name="msgs">
<xsl:for-each select="ancestoer::msg">
<msg><xsl:value-of select="@type"/></msg>
</xsl:for-each>
</xsl:variable>
</xsl:template>
我期望的输出将是:
<msg>test</msg>
但它不能按预期工作。有人可以帮忙吗?
输入XML有一个元素'cnts',它与XSLT中的'contents'不同。为什么要这么做?更新XML以完成。有一个变量来存储一些值不会输出它,向我们展示您的完整XSLT!而且,这个轴被拼成“祖先”! –