Thanks to Stack Overflow and @michael.hor257k I was able to update namespaces successfully in my XML Document.
Now, there is only one problem.
My SAP System couldn't understand a couple of fields from XSD and thus added its own namespace to accommodate to the XML Schema.
This is solvable through SAP, but we don't have that software(SPROXY) installed yet.
So, I have to achieve this using XSLT 1.0.
My original XML was:
<?xml version="1.0" encoding="UTF-8"?>
<n0:eCPR xmlns:prx="urn:sap.com:proxy:DV4:/1SAI/TAS1F59A417878D36573F1D:700:2013/05/24" xmlns:n0="http://www.dir.ca.gov/dlse/CPR-Prod-Test/CPR.xsd">
<n0:employees>
<n0:employee>
<n0:name id="20019768">Paul John</n0:name>
</n0:employee>
</n0:employees>
</n0:eCPR>
And the XSLT Used to achieve the required output below:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:CPR="http://www.dir.ca.gov/dlse/CPR-Prod-Test/CPR.xsd">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*">
<xsl:element name="CPR:{local-name()}">
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
After updating with the current namespace my XML(Where the error is) Looks like
<?xml version="1.0" encoding="UTF-8"?>
<CPR:eCPR xmlns:CPR="http://www.dir.ca.gov/dlse/CPR-Prod-Test/CPR.xsd">
<CPR:projectInfo>
<CPR:awardingBody xmlns:asx="http://www.sap.com/abapxml" asx:root=""/>
<CPR:contractAgencyID xmlns:asx="http://www.sap.com/abapxml" asx:root=""/>
<CPR:contractAgency/>
<CPR:projectName xmlns:asx="http://www.sap.com/abapxml" asx:root=""/>
<CPR:projectID/>
<CPR:awardingBodyID/>
<CPR:projectNum/>
<CPR:contractID/>
So, the nodes awardingBody,contractAgencyID and Project Name are the fields which couldn't got properly converted by the system.( The nodes with xmlns:asx namespace )
I need to remove these namespaces. Is it possible through XSLT. Condition: Remove namespace of only those entries whose namespace is http://www.sap.com/abapxml or I can provide a name of nodes(as they are fixed)
What the ideal structure should be:
<?xml version="1.0" encoding="UTF-8"?>
<CPR:eCPR xmlns:CPR="http://www.dir.ca.gov/dlse/CPR-Prod-Test/CPR.xsd">
<CPR:projectInfo>
<CPR:awardingBody/>
<CPR:contractAgencyID />
<CPR:contractAgency/>
<CPR:projectName/>
<CPR:projectID/>
<CPR:awardingBodyID/>
<CPR:projectNum/>
<CPR:contractID/>
Thanks
awardingBody,contractAgencyIDandProject Nameelements with therootattribute. The input you show us could not produce the output you claim.