How do we copy all of or a portion of an XML document exactly? The following code
fragment shows how
to do that exactly of our requirement. Using this
XSLT template for an entire XSLT file or for a portion of a document,
we will copy the contents of a particular node exactly.
XSLT Tutorial section of XSLT Copying will be very useful if we want to leave a large portion of a document unchanged.
<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="XSLT_Copying_Example.xsl"?>
<rootNode>
Well Come at
<nestedElement>
Global Guide Line
<innerElement>
, enjoy XSLT Copying examples.
</innerElement>
</nestedElement>
</rootNode>
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="nestedElement">
<nestedElement>
XSLT Tutorial at Global Guide Line
<xsl:apply-templates select="*" />
</nestedElement>
</xsl:template>
</xsl:stylesheet>
View complete sources and outputs by simply clicking on file name of XSLT, XML
and Out Put of XSLT Copying Example.