I need to remove the namespace prefix from some xml but keep the namespace using XSLT.
This is exactly as described here - How to remove namespace prefix leaving namespace value (XSLT)?
This works fine when I test with XML copy editor but the application I'm working on in is using XSLTC. Unfortunately it does not work with XSLTC. Any ideas on how to get it working?
Here is the source xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ns0:eBooking xmlns:ns0="http://test.com">
<ns0:eventInfo Id="ID00000000000000000020" version="1">
<ns0:Event>
<ns0:tpAmb>1</ns0:tpAmb>
<ns0:procEmi>1</ns0:procEmi>
</ns0:Event>
</ns0:eventInfo>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference URI="#ID00000000000000000020">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>p42saeKIMnVR7/P/nzen8mTsq94=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>SzLt....==</SignatureValue>
<KeyInfo>
<X509Data>
<X509Certificate>MIIHdzCCBV.......==</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</ns0:eBooking>
Here is the xslt:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns0="http://test.com"
xmlns="http://test.com" >
<xsl:output indent="yes"/>
<xsl:template match="ns0:*">
<xsl:element name="{local-name()}" >
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
When using JDK XSLTC this gives:
<?xml version="1.0" encoding="UTF-8"?>
<eBooking>
<eventInfo Id="ID00000000000000000020" version="1">
<Event>
<tpAmb>1</tpAmb>
<procEmi>1</procEmi>
</Event>
</eventInfo>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#" **xmlns:ns0="http://test.com"**>
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference URI="#ID00000000000000000020">
<Transforms>
<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>p42saeKIMnVR7/P/nzen8mTsq94=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>SzLt....==</SignatureValue>
<KeyInfo>
<X509Data>
<X509Certificate>MIIHdzCCBV.......==</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</eBooking>
It works fine if I test with xml copy editor.