Skip to Content

Need help in XSLT code to change namespace

Requesting you to help me with the XSLT Mapping code to convert the below source structure namespace(highlighted) with the target structure namespace(highlighted) format

  1. Source Structure Namespace :

http://www.w3.org/2001/XMLSchema-instance” xmlns:soapenv=” http://schemas.xmlsoap.org/soap/envelope/” xmlns:dssuid=”urn:autoid:specification:universal:Identifier:xml:schema:1″ xmlns:dsscore=”urn:autoid:specification:interchange:PMLCore:xml:schema:1″> <PurchaseQuery> <EventDate>20170926</EventDate> <bizLocation> <id>urn:ddd:id:sgln:0315563.00000.0</id> </bizLocation> <Serialization> <BATCH_ID>3091145AB</BATCH_ID> <EXPIRATION_DATE>20190504</EXPIRATION_DATE> <PRODUCTION_DATE>20170505</PRODUCTION_DATE> <GTIN>04028691544401</GTIN> <Count>8088</Count> </Serialization> </PurchaseQuery> </PurchaseOrderDocument>

Target Structure should be like

<?xml version=”1.0″ encoding=”UTF-8″?> <ns0:PurchaseOrderDocument creationDate=”2017-09-26T18:37:48.837Z” xmlns:ns0=”urn:global:mns:PurchaseOrder”> <PurchaseQuery> <EventDate>20170926</EventDate> <bizLocation> <id>urn:ddd:id:sgln:0315563.00000.0</id> </bizLocation> <Serialization> <BATCH_ID>3091145AB</BATCH_ID> <EXPIRATION_DATE>20190504</EXPIRATION_DATE> <PRODUCTION_DATE>20170505</PRODUCTION_DATE> <GTIN>04028691544401</GTIN> <Count>8088</Count> </Serialization> </PurchaseQuery> </ns0:PurchaseOrderDocument>

The rootnode contains creationdate which will get value from source structure. Iam facing difficulty as the rootnode has this field.

Kindly help me with your solutions

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Oct 03, 2017 at 03:28 PM

    Hello PI User,

    Please check this blog - it should help you solve your issue:

    https://stackoverflow.com/questions/15981488/how-can-i-add-namespaces-to-the-root-element-of-my-xml-using-xslt

    Best regards, Peter

    Add comment
    10|10000 characters needed characters exceeded