user3767641
user3767641

Reputation: 325

XSLT transformation copy node

How do i just copy node without any of the child nodes during transformation

<xsl:apply-templates mode="copy" select="test" />

here in the above example i just want to copy test node(none of the child nodes of test should be selected in transformation??

Upvotes: 0

Views: 252

Answers (1)

michael.hor257k
michael.hor257k

Reputation: 116982

You could add a template like this:

<xsl:template match="test" mode="copy">
    <xsl:copy/>
</xsl:template>

To copy the attributes, use:

<xsl:template match="test" mode="copy">
    <xsl:copy>
        <xsl:copy-of select="@*"/>
    </xsl:copy>
</xsl:template>

Upvotes: 1

Related Questions