Additional Blogs by SAP
cancel
Showing results for 
Search instead for 
Did you mean: 
danny_deroovere
Participant
0 Kudos

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="*http://tatis.com/test/schemas/** testcdata.xsd" xmlns:hr="*http://danny.com/manifest/schemas/*" xmlns:xsi="*http://www.w3.org/2001/XMLSchema-instance*"><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="*http://www.w3.org/1999/XSL/Transform*" xmlns:ns0="*http://tatis.com/schemas/msg/envelope/ext*">

2 Comments