<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"><!-- 
	Copies all the element and text node children of the current node
	    Use this to avoid copy-of which all copies the namespace attributes -->

   <xsl:template name="copy-elements-and-text">
      <xsl:for-each select="*|text()">
         <xsl:apply-templates select="." mode="copy-elements-and-text"/>
      </xsl:for-each>
   </xsl:template>

   <xsl:template match="*" mode="copy-elements-and-text">
      <xsl:element name="{name()}">
         <xsl:for-each select="@*">
            <xsl:attribute name="{name()}">
               <xsl:value-of select="."/>
            </xsl:attribute>
         </xsl:for-each>
         <xsl:call-template name="copy-elements-and-text"/>
      </xsl:element>
   </xsl:template>

   <xsl:template match="text()" mode="copy-elements-and-text">
      <xsl:copy-of select="."/>
   </xsl:template>

</xsl:stylesheet>

