xslt 匹配除特定节点之外的所有节点 [英] xslt match all nodes except a specific one
本文介绍了xslt 匹配除特定节点之外的所有节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想匹配我的 xml 中的所有节点,除了一个,即 docbody.类似的东西
I want to match all nodes in my xml except one ie docbody. Something like
<xsl:template match="@*|node()[not(docBody)]" name="identity">
<xsl:copy>
<xsl:apply-templates select="@*|node()">
</xsl:copy>
</xsl:template>
我是如何做到这一点的,我试过上面的方法.
How do i achieve this, i tried the way above.
推荐答案
匹配除此之外的所有内容(添加 self::
)并覆盖 docBody
的默认模板(没有它,docBody
的内容仍会被打印出来):
Match all but this one (adding self::
) and overwrite the default template for docBody
(without it the contents of docBody
would still be printed):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
<xsl:template match="@*|node()[not(self::docBody)]" name="identity">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<!-- overwrite the default template -->
<xsl:template match="docBody">
</xsl:template>
</xsl:stylesheet>
这篇关于xslt 匹配除特定节点之外的所有节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文