Changing namespace for XML file in XSL Translation
This transformation:
<xsl:template match="*"> <xsl:element name="cmp:{name()}" namespace="CompanyURL"> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </xsl:element> </xsl:template> <xsl:template match="/*"> <cmp:container xmlns:cmp="CompanyURL"> <xsl:copy-of select="@*"/> <xsl:apply-templates/> </cmp:container> </xsl:template></xsl:stylesheet>
when performed on the provided XML document:
<foo xmlns="companyURL"> <num1>asdf</num1> <num2>ghjkl</num2></foo>
produces the wanted, correct result:
<cmp:container xmlns:cmp="CompanyURL"> <cmp:num1>asdf</cmp:num1> <cmp:num2>ghjkl</cmp:num2></cmp:container>