<events>
<main>
<action>modification</action>
<subAction>weights</subAction>
</main>
</events>
<SeriesSet>
<Series id="Price_0">
<seriesBodies>
<SeriesBody>
<DataSeriesBodyType>Do Not Copy</DataSeriesBodyType>
</SeriesBody>
</SeriesBodies>
</Series>
</SeriesSet>
如何复制所有 xml 并排除 DataSeriesBodyType 元素
您只需使用身份模板(如您所使用的那样),然后使用与 DataSeriesBodyType 匹配的模板,该模板不执行任何操作。
代码是:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<!-- Identity template : copy all text nodes, elements and attributes -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<!-- When matching DataSeriesBodyType: do nothing -->
<xsl:template match="DataSeriesBodyType" />
</xsl:stylesheet>
如果要规范化输出以删除空数据文本节点,请向先前的样式表添加以下模板:
<xsl:template match="text()">
<xsl:value-of select="normalize-space()" />
</xsl:template>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)