Page tree
Skip to end of metadata
Go to start of metadata

Changing Namespaces and the encoding format of XML:

INPUT

OUTPUT

<?xml version="1.0" encoding="utf-8"?>

<ns1:Test xmlns:ns1="ABC.interface">
<?xml version="1.0" encoding="ISO-8859-1"?>

<if:Test xmlns:if="ABC.interface">

We can change the namespace ns1 to if and the encoding format "utf-8" to "ISO-8859-1" by using the SAP Adapter module called XMLAnonymizer in the receiver communication channel.
Steps:
Receiver communication channel -->  Module tab --> enter the following data

Module Name = AF_Modules/XMLAnonymizerBean

Module Type = Local Enterprise Bean

Module key = 0

Module Configuration

anonymizer.acceptNamespaces = ABC.interface if

anonymizer.encoding = ISO-8859-1

anonymizer.quote = '

Adding additional namspaces and map only selected fields using XSLT mapping:


  INPUTOUTPUT<?xml version="1.0" encoding="utf-8"?>

<ns1:Test xmlns:ns1="ABC.interface"><?xml version="1.0" encoding="utf-8"?>

<ns1:Test xmlns:ns1="ABC.interface" xsi:schemaLocation="ABC.interface Test.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

So to add additional xml namespace instances we can use XSLT mapping but suppose that we have the XSD files given from our clients and the graphical mapping is very big so instead of mapping the whole scenario again with XSLT, you can just map the XML instance in XSLT having the rest mapping of graphical mapping intact.

Steps:
In the interface mapping, configure the graphical mapping and the XSLT mapping in a sequence.

XSLT Mapping

<xsl:template match="/">

<ns1:Test xmlns:ns1="ABC.interface"

xsi:schemaLocation="ABC.interface Test.xsd"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<xsl:copy-of select="//SubData1"/>

<xsl:copy-of select="//SubData2"/>

........

<xsl:copy-of select="/ns1:Test/SubData100"/>

</ns1:Test>

</xsl:template>

In XSLT mapping, "copy-of" will generate the rest structure with the nodes and sub nodes.

2 Comments

  1. Unknown User (98of6kk3)

    Hi new in PI,

    I need to add several namespaces at root, 

    <?xml version="1.0" encoding="UTF-8"?><root xsi:schemaLocation="something" xmlns="somethingelse" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><rest of the xml structure></root>

    Im using the graphical interface to generate the XML, and its works fine but only with one namespace.

    <?xml version="1.0" encoding="UTF-8"?><root xmlns="somethingelse"><rest of the xml structure></root>

    Where I could find the interface mapping to configure the graphical mapping and the XSLT mapping in a sequence.

    Im using the Enterprise Builder. But I dont know where to add the XSLT mapping.

    (Any link would be great)

  2. Unknown User (98of6kk3)

    Hi new in PI,

    I need to add several namespaces at root, 

    <?xml version="1.0" encoding="UTF-8"?><root xsi:schemaLocation="something" xmlns="somethingelse" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><rest of the xml structure></root>

    Im using the graphical interface to generate the XML, and its works fine but only with one namespace.

    <?xml version="1.0" encoding="UTF-8"?><root xmlns="somethingelse"><rest of the xml structure></root>

    Where I could find the interface mapping to configure the graphical mapping and the XSLT mapping in a sequence.

    Im using the Enterprise Builder. But I dont know where to add the XSLT mapping.

    (Any link would be great)

    thanks