XSLT transformation for namespace

chefayman

New Member
\[code\]<htmL><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <tns:send xmlns:tns="http://www.test.com/Service/v3"> <NS2:Message release="006" version="010" xmlns:NS2="http://www.ncpdp.org/schema/SCRIPT"> <NS2:Body> <NS2:New> <NS2:Pharmacy> <NS2:Identification> <NS2:ID> <NS2:IDValue>01017</NS2:IDValue> <NS2:IDQualifier>94</NS2:IDQualifier> <NS2:IDRegion>SCA</NS2:IDRegion> <NS2:IDState>CA</NS2:IDState> </NS2:ID> </NS2:New> </NS2:Body> </NS2:Message> </tns:send> </soapenv:Body></soapenv:Envelope></html>\[/code\]I have this xml which is on schema version 3.0 http://www.test.com/Service/v3 . I need to downgrade it to version 1 http://www.test.com/Service/v1. To do that i am using a XSL to transform it.\[code\]<html><?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:booga="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.test.com/Service/v3" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:src="http://www.ncpdp.org/schema/SCRIPT"> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/><xsl:strip-space elements="*"/><xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="tns:*"> <!-- Output a new element in the new namespace --> <xsl:element name="tns:{local-name()}" namespace="http://www.test.com/Service/v1"> <!-- Copy all child attributes and nodes <xsl:apply-templates select="node()|@*"/> --> <xsl:apply-templates /> </xsl:element> </xsl:template></xsl:stylesheet></html>\[/code\]but i get a result like this \[code\]<html><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <tns:sendNewRx xmlns:tns="http://www.test.com/Service/v1"> <NS2:Message release="006" version="010" xmlns:NS2="http://www.ncpdp.org/schema/SCRIPT" xmlns:tns="http://www.test.com/Service/v3"> <NS2:Body> <NS2:New> <NS2:Pharmacy> <NS2:Identification> <NS2:ID> <NS2:IDValue>01017</NS2:IDValue> <NS2:IDQualifier>94</NS2:IDQualifier> <NS2:IDRegion>SCA</NS2:IDRegion> </NS2:ID> </NS2:NewRx> </NS2:Body> </NS2:Message> </tns:send> </soapenv:Body></soapenv:Envelope></html>\[/code\]In my output XML i get this added \[code\]<NS2:Message release="006" version="010" xmlns:NS2="http://www.ncpdp.org/schema/SCRIPT" xmlns:tns="http://eps.pdxinc.com/webservice/Rxservice/v3"> xmlns:tns="http://eps.pdxinc.com/webservice/Rxservice/v3 \[/code\]this was not there in the input xml. There is something which i am missing. Will really appreciate if someone could point out the issue.
 
Back
Top