Hello Micheal & Sam,
Thanks for your replies... These solution worked out.... and i got proper result...and also thanks for informative explanation
In the solution I was getting an additional namespace attribute in result. Although that was not effecting the parsing of the response as you said..
As Micheal suggested one alternate solution also , in that he was mentioning that... these additional namespace will not come; i.e. using <xsl:element> instead of the <xsl:copy>, I tried with the following
---------------------------------------------------
Input xml
---------------------------------------------------
Code:
<?xml version="1.0" encoding="UTF-8"?>
<impl:requestData xmlns:impl="oldNameSpace">
<impl:xmlString ChangeDate="2008-12-18T14:47:11.773+01:00"
IdentificationNumber="WDDKJ5GBXAF000229" OrderNumber="08 295 70821"
ProductionNumber="1700158">
<ServiceTool ExecutionTime="2008-12-18T14:47:11.773+01:00"
UserID="kris" Version="1.1.1" />
<Component Version="1.1.1" />
</impl:xmlString>
</impl:requestData>
---------------------------------------------------
desired result
---------------------------------------------------
Code:
<?xml version="1.0" encoding="UTF-8"?>
<impl:requestData xmlns:impl="newNameSpace">
<xmlReport ChangeDate="2008-12-18T14:47:11.773+01:00"
IdentificationNumber="WDDKJ5GBXAF000229" OrderNumber="08 295 70821"
ProductionNumber="1700158">
<ServiceTool ExecutionTime="2008-12-18T14:47:11.773+01:00"
UserID="kris" Version="1.1.1" />
<Component Version="1.1.1" />
</xmlReport>
</impl:requestData>
---------------------------------------------------
transformation file
---------------------------------------------------
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ser="newNameSpace" xmlns:source="oldNameSpace"
version="1.0">
<xsl:output method="xml" encoding="iso-8859-1" indent="yes" />
<xsl:template match="source:*">
<xsl:element name="{local-name()}" namespace="newNameSpace">
<xsl:copy-of select="@*|node()" >
<xsl:apply-templates select="@*|node()"/>
</xsl:copy-of>
</xsl:element>
</xsl:template>
<xsl:template match="source:xmlString">
<xmlReport>
<xsl:element name="{local-name()}" namespace="newNameSpace">
<xsl:copy-of select="@*|node()" />
<xsl:apply-templates select="@*|node()" />
</xsl:element>
</xmlReport>
</xsl:template>
</xsl:stylesheet>
So here in result additional name space attributes; mainly for the child elements <ServiceTool> <Component> was coming while using <xsl:copy>. Although it will not effect the parsing of the document... but My XML is too large ( there are hundreds of <ServiceTool> and <Component> elements ) and these additional attributes are unnecessarily increasing the size of message.
can you please help in this....
Thanks a lot.
Krishna