Skip to Content
avatar image
Former Member

How do I map CData content in ESR?

Hi,

I'm trying to map the following message:

<XML_Message>

<Data>

<Payload><![CDATA[<p>Just some example</p>]]></Payload>

</Data>

</XML_Message>

Unfortunately, the CData section is removed and all the HTML tags are escaped when mapping to another message. I don't use XSLT, so maybe that is my problem. I want the message to stay like it is, with CData and all.

Can someone tell me what to do?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 24, 2016 at 10:45 AM

    Hi Zakaria,

    Use below UDF to keep CDATA in the output.

    public String retainCDATA(String input, Container container) throws StreamTransformationException {
    		return "<![CDATA[" + input + "]]>";
    	}
    

    Mapping Test:

    In the mapping test tab it shows with escape characters because with in the element less than and greater than symbols are by default escaped but when i open the output in XML Notepad it shows CDATA.

    Regards,

    Praveen.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 24, 2016 at 11:50 AM

    HI Zankaria,

    My few cents

    the CData section is removed and all the HTML tags are escaped when mapping to another message

    I think you are viewing directly the browser, you should check the source code and in this place you will not have the CDATA tags escaped.

    On another hand Praveen has suggested a good way to start to work with the CDATA tags. Also you can review anohter blogs in the SCN like this

    https://blogs.sap.com/2012/03/08/integrating-cdata-based-web-service-with-sap-pi-a-generic-approach/

    Regards.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 24, 2016 at 02:35 PM

    Note: The questions-marks cannot be rendered correctly by the website. I therefore am uploading this jpg for you to know what the questions marks really are:

    Hi Praveen,

    I have a problem with the following payload:

    <Payload><![CDATA[<p>The ���� ’s</p>]]></Payload>

    The payload contains hexadecimal representations of certain characters. As a result, this XML won't parse, so I have to include it in CData. Then two or three message mappings need to happen. So in short:

    I want:

    <Payload><![CDATA[<p>The ���� ’s</p>]]></Payload>

    to stay

    <Payload><![CDATA[<p>The ���� ’s</p>]]></Payload>

    after three message mappings

    ,

    Hi Praveen,

    Thanks for the help, but It's not going to work. I am dealing with hexadecimal representations of certain html characters.

    I have the scenario of having two or three message mappings after each other. In the first mapping I can use your function with this payload:

    <Payload><![CDATA[<p>the ���� ’s</p>]]></Payload>

    (Parsing XML with this payload without CData will not work)

    So the actual question is. Can I go from:

    1. <Payload><![CDATA[<p>the ���� ’s</p>]]></Payload>

    to

    2. <Payload><![CDATA[<p>the ���� ’s</p>]]></Payload>

    over two or three message mappings? I don't want anything changed

    Add comment
    10|10000 characters needed characters exceeded