Skip to end of metadata
Go to start of metadata

XML Namespace Manipulation Using XSL

Scenario:

Some time, we have to add additional XML namespace at certain element of the XML as to comply with the receiver system requirements. Please see the difference between source and target XML below for instance.

Source Structure:

<?xmlversion="1.0" encoding="UTF-8"?>

<RequestService xmlns="urn:axon.com.general">

            <ServiceName>CreateMaterial</ServiceName>

            <ServiceVersion>1.0</ServiceVersion>

            <MT_Material>

                        <Material>

                                    <MaterialNo>123</MaterialNo>

                                    <MaterialType>ROH</MaterialType>

                                    <MaterialGroup>10</MaterialGroup>

                                    <BaseUnit>Kilogram</BaseUnit>

                                    <OrderUnit>1</OrderUnit>

                                    <Date>22/06/2008</Date>

                        </Material>

            </MT_Material>

</RequestService>

Target Structure:

<?xmlversion="1.0" encoding="UTF-8"?>

<RequestService xmlns="urn:axon.com.general">

            <ServiceName>CreateMaterial</ServiceName>

            <ServiceVersion>1.0</ServiceVersion>

            <MT_Material xmlns="urn:axon.com.http2file:receiver">

                        <Material>

                                    <MaterialNo>123</MaterialNo>

                                    <MaterialType>ROH</MaterialType>

                                    <MaterialGroup>10</MaterialGroup>

                                    <BaseUnit>Kilogram</BaseUnit>

                                    <OrderUnit>1</OrderUnit>

                                    <Date>22/06/2008</Date>

                        </Material>

            </MT_Material>

</RequestService>

As you can see from the target structure that complexelement MT_Material has different name space "urn:axon.com.http2file:receiver" which is different from root element name space "urn:axon.com.general". So the challenge is how we can add additional namespace at certain element level of the XML. One solution is by using XSL to do souce and target structure mapping.

Solution:

1.     Source ToTarget Structure Mapping

Excerpt is the XSL required to add additional namespace tothe complex element_MT.
 

If you have XML editor then, you can perform testing to make sure that the transformation is done correctly. Please proceed with the next step to use the XSL in XI design and configuration.

2.     XI Design and Configuration

a.       Zip the XSL and upload the XSL to XI repository.

b.      Create message interface mapping and use the XSL as the mapping program

c.       Don't forget to use the interface mapping in the interface determination step

  • No labels