Skip to Content

How to map CDATA to a structured message in XI

Recently, I’ve been asked to map generic message data embedded in a XML body’s CDATA container to a complete message structure defined in XI.
When I searched on SDN, I could only find information about the other way around (wrapping XML structured data  into CDATA) which is why I’m posting this thread. The solution is so easy, yet doesn’t seem to be straightforward, which is why I absolutely wanted to document  and share it with you.

This is the message  sent to SAP PI:

<?xml version=”1.0″ encoding=”UTF-8″?><br /><Envelope><br /> <Header><br />  <To>Danny</To><br />  <MsgType>test</MsgType><br /> </Header><br /> <Body><![CDATA[<hr:TestMsgRequest xsi:schemaLocation=”*** testcdata.xsd” xmlns:hr=”**” xmlns:xsi=”**“><strong><hr:town>Somewhere</hr:town><hr:country>Belgium<br /></hr:country></hr:address></hr:customer></hr:TestMsgRequest>]]><br /> </Body><br /></Envelope><br /></strong><br />As you see it consists of a Header and a Body. The Body contains the CDATA which should be unserialized and mapped to the following message structure:</p><p><customer><br /> <name>aaaaaaaaaaaaaaaaaaaaaaa</name><br /> <code>1234</code><br /> <address> <br />  <name>test Customer</name><br />  <postalcode>BE9876</postalcode><br />  <town>Somewhere</town><br />  <country>Belgium</country><br /> </address><br /></customer><br /><br />I’ve created an xslt mapping, imported it as an archive and used the XSLT mapping in the interface mapping.</p><p>The following source code did the trick:</p><p>
<xsl:stylesheet version=”1.0″ xmlns:xsl=”**” xmlns:ns0=”**“>

You must be Logged on to comment or reply to a post.
  • Weblogs relevant:->
      The above weblog telling about how to get structure from a field(i.e. in source xml file) (Field -> xml file)
      the below weblog telling about how to put xml structure in a field( Target xml):
      These two weblogs are giving valuable information (  with help of CDATA tag in XSLT ).

    XI: XML node into a string with graphical mapping?   
    The specified item was not found. ( xml file  -> field of target structure.)

    XML Result from JDBC Adapter Stored Procedure  -> java mapping
    XML Result from JDBC Adapter Stored Procedure