<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>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。