Skip to Content
0

How do I map CData content in ESR?

Oct 24, 2016 at 07:59 AM

137

avatar image

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?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Praveen Gandepalli Oct 24, 2016 at 10:45 AM
1

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.


Show 1 Share
10 |10000 characters needed characters left characters exceeded

See my reply. Thank you

0
Iñaki Vila Oct 24, 2016 at 11:50 AM
0

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.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

See my reply. Thank you

0
Zakaria el Bakkali Oct 24, 2016 at 02:35 PM
0

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


Share
10 |10000 characters needed characters left characters exceeded