Reputation: 37
<Tag1>
<dummy><name>qwert</name><id>123</id></dummy>
<dummy><name>wert</name><id>023</id></dummy>
<dummy><name>hfj</name><id>103</id></dummy>
</Tag1>
I have above XML for which I want to strip the in the XML output file
Desired O/p:
<Tag1>
<name>qwert</name><id>123</id>
<name>wert</name><id>023</id>
<name>hfj</name><id>103</id>
</Tag1>
Also I tried using the below XSLT
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="dummy"/>
</xsl:stylesheet>
It's removing as well everything underneath it
Upvotes: 1
Views: 131
Reputation: 70608
You need to do this instead, to ensure the children of dummy
are still selected
<xsl:template match="dummy">
<xsl:apply-templates />
</xsl:template>
EDIT: Here is the complete spreadsheet
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="dummy">
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>
Upvotes: 1