【发布时间】:2020-07-24 04:48:00
【问题描述】:
我有带有数据的 xml。我需要删除所有没有值的空标签。但我不必删除 2 个特定的 xml 标签,即使标签是空值。
<Executive>
<title></title>
<executivename></executivename>
</Executive>
我的 xml 很大,有很多元素,但上面的 2 个元素(标题和执行名称)即使它们有空值,我也不必删除。下面是我用来删除所有空值标签的 xslt 代码。但我不知道如何排除上述两个元素。有人可以帮我解决这个问题吗?
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match=
"*[not(@*|*|comment()|processing-instruction())
and normalize-space()=''
]"/>
</xsl:template>
</xsl:stylesheet>
【问题讨论】: