I get this request all the time so here is an example. It also shows you how to handle cases where you want to do something specific to certain elements while doing the copy.
<?xml version="1.0" encoding="UTF-8" ?> <!-- Document : Create Copy of Document Created on : April 3, 2006 Author : sgmlxmldotnet Comment Demo file for Creating an Exact Copy of the document. --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- template rule matching source root element --> <xsl:template match="/|*|comment()"> <xsl:call-template name="do_copy"/> </xsl:template> <!-- Add additional template matches here --> <!-- Named Templates --> <!-- Copy current element and attribute nodes --> <xsl:template name="do_copy"> <xsl:copy> <xsl:for-each select="@*"> <xsl:copy/> </xsl:for-each> <xsl:apply-templates/> </xsl:copy> </xsl:template> </xsl:stylesheet> |