Reputation: 1020
This may be a simple xslt problem. I have xml like follows,
<doc>
<chap>
<p>This is a para</p>
</chap>
</doc>
what I need is remove both <doc>
and <chap>
node and add node to the result three.
SO the output should be,
<new>
<p>This is a para</p>
</new>
when I write a template to
<xsl:template match="doc">
<new><xsl:apply templates/></new>
</template>
it adds <chap>
to result tree.
when I write a template to <chap>
<xsl:template match="chap">
<new><xsl:apply templates/></new>
</template>
it adds <doc>
to result tree.
and I cannot suppress any element like <xsl:template match="chap"/>
. as it removes child nodes as well.
How Can I get desired output using xsl?
Upvotes: 0
Views: 175
Reputation: 167716
Use <xsl:template match="doc"><xsl:apply-templates/><xsl:template>
, then you can use your
<xsl:template match="chap">
<new><xsl:apply templates/></new>
</template>
together with the identity transformation template you probably have too (although you haven't shown it).
Upvotes: 1