I have this input XML to which I have to apply XSL and convert it to another XML, which is on a higher version. Suppose V3. Thus, the input XML file is on version V1.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:NS1="http://www.test1/Error/v1" xmlns:NS2="http://www.test1/Error/schema/SCRIPT" xmlns:tns="http://www.test1/webservice/Service/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <tns:Sample> <NS2:Message release="006" version="010"> <NS2:Header> <NS2:TestMessage>1</NS2:TestMessage> </NS2:Header> <NS2:Body> <NS2:SampleTx> <NS2:Element1> <NS2:IdName> <NS2:ID> <NS2:IDValue>114</NS2:IDValue> </NS2:ID> </NS2:IdName> </NS2:Element1> </NS2:SampleTx> </NS2:Body> </NS2:Message> </tns:Sample> </soapenv:Body> </soapenv:Envelope>
XSL which I apply
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:djh="http://www.test1/webservice/Service/v1" xmlns:NS1="http://www.test1/Error/v1" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <xsl:output indent="yes"/> <xsl:template match="@*|comment()|processing-instruction()"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="djh:*"> <xsl:element name="{name()}" namespace="http://www.test1/webservice/Service/v3"> <xsl:apply-templates select="@*|node()"/> </xsl:element> </xsl:template> <xsl:template match="*"> <xsl:element name="{name()}"> <xsl:apply-templates select="@*|node()"/> </xsl:element> </xsl:template> </xsl:stylesheet>
and the conclusion that I get is
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <tns:sendCancelRx xmlns:tns="http://www.test1/webservice/Service/v3"> <NS2:Message release="006" version="010" xmlns:NS2="http://www.ncpdp.org/schema/SCRIPT"> <NS2:Header> <NS2:TestMessage>1</NS2:TestMessage> </NS2:Header> <NS2:Body> <NS2:SampleTx> <NS2:Element1> <NS2:IdName> <NS2:ID> <NS2:IDValue>114</NS2:IDValue> </NS2:ID> </NS2:IdName> </NS2:Element1> </NS2:SampleTx> </NS2:Body> </NS2:Message> </tns:sendCancelRx> </soapenv:Body> </soapenv:Envelope>
It removes all namespace declarations from xmlns:NS1="http://www.test1/Error/v1" xmlns:NS2="http://www.test1/Error/schema/SCRIPT" xmlns:tns="http://www.test1/webservice/Service/v1" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
and the conclusion I want
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:NS1="http://www.test1/Error/v3" xmlns:NS2="http://www.test1/Error/schema/SCRIPT" xmlns:tns="http://www.test1/webservice/Service/v3" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <tns:Test> <NS2:Message release="006" version="010"> <NS2:Header> <NS2:TestMessage>1</NS2:TestMessage> </NS2:Header> <NS2:Body> <NS2:SampleTx> <NS2:Element1> <NS2:IdName> <NS2:ID> <NS2:IDValue>114</NS2:IDValue> </NS2:ID> </NS2:IdName> </NS2:Element1> </NS2:SampleTx> </NS2:Body> </NS2:Message> </tns:Test> </soapenv:Body> </soapenv:Envelope>
I would appreciate it if someone could tell me what is missing in my XSL.
Guest source share