<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>
How do i copy all xml and exclude the DataSeriesBodyType element
Optional Attributes exclude-result-prefixes. Specifies any namespace used in this document that should not be sent to the output document. The list is whitespace separated. extension-element-prefixes. Specifies a space-separated list of any namespace prefixes for extension elements in this document.
Returns the contents of the current group selected by xsl:for-each-group. Available in XSLT 2.0 and later versions. Available in all Saxon editions. current-group() ➔ item()*
Specifies the format pattern. Here are some of the characters used in the formatting pattern: 0 (Digit)
The following-sibling axis indicates all the nodes that have the same parent as the context node and appear after the context node in the source document.
You just have to use the identity template (as you were using) and then use a template matching DataSeriesBodyType which does nothing.
The code would be:
<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>
If you want to normalize the output to remove empty data text nodes, then add to the previous stylesheet the following template:
<xsl:template match="text()">
<xsl:value-of select="normalize-space()" />
</xsl:template>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With