I have a program that generates XML Output. The program with default namespace looks like this:
<n0:eCPR xmlns:n0="http://www.dir.ca.gov/dlse/CPR-Prod-Test/CPR.xsd"
xmlns:prx="urn:sap.com:proxy:DV4:/1SAI/TAS1F59A417878D36573F1D:700:2013/05/24">
<n0:contractorInfo>
<n0:contractorName>test_user</n0:contractorName>
<n0:contractorAddress>
<n0:street></n0:street>
<n0:city></n0:city>
<n0:state/>
<n0:zip/>
</n0:contractorAddress>
</n0:contractorInfo>
</n0:eCPR>
If i remove the default namespace, the output looks like this
<eCPR>
<contractorInfo>
<contractorName>test_user</contractorName>
<contractorAddress>
<street></street>
<city></city>
<state/>
<zip/>
</contractorAddress>
<insuranceNum></insuranceNum>
<contractorEmail></contractorEmail>
</contractorInfo>
</eCPR>
What i want it to look as
<CPR:eCPR xmlns:CPR="http://www.dir.ca.gov/dlse/CPR-Prod-Test/CPR.xsd">
<CPR:contractorInfo>
<CPR:contractorName>test_user</CPR:contractorName>
<CPR:contractorAddress>
<CPR:street>999 Carrier Rd</CPR:street>
<CPR:city>Oakland</CPR:city>
<CPR:state>CA</CPR:state>
<CPR:zip>94612</CPR:zip>
</CPR:contractorAddress>
</CPR:contractorInfo>
</CPR:eCPR>
The code i used to remove the default namespace was:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/|comment()|processing-instruction()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
Kindly, help out.
Thanks