So I have an input file that uses my company\'s namespace in the default namespace (xmlns=\"companyURL\"
) but I want my output file to use something other than the
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>