在我的XSL转换期间,我想用ContextID =" de_DE"删除所有标签。这意味着以下XML:
<Values>
<Value AttributeID="TEST" ContextID="de_DE" QualifierID="de">1234</Value>
<Value AttributeID="TEST" ContextID="fr_FR" QualifierID="fr">1234</Value>
<Value AttributeID="TEST100" ContextID="de_DE" QualifierID="de">abcd</Value>
<Value AttributeID="TEST100" ContextID="fr_FR" QualifierID="fr">abcd</Value>
</Values>
将成为:
<Values>
<Value AttributeID="TEST" ContextID="fr_FR" QualifierID="fr">1234</Value>
<Value AttributeID="TEST100" ContextID="fr_FR" QualifierID="fr">abcd</Value>
</Values>
我如何实现这一目标?
提前致谢!
答案 0 :(得分:0)
XSLT没有'删除'的概念。您可以通过匹配输入文档并对其执行任何操作来排除输入文档中的节点。 XSLT处理器确实具有特异性概念,因此更具体的模板会覆盖不太具体的模板。
类似的东西:
<!-- Matches all Value elements and copies them verbatim -->
<xsl:template match="Value">
<xsl:copy/>
</xsl:template>
<!-- Matches all Value elements whose ContextID is 'de_DE' in preference to the less-specific template, and does nothing -->
<xsl:template match="Value[@ContextID='de_DE']"/>