Skip to Content
0

How to add CDATA section in simple transformation

Jun 11, 2017 at 10:08 PM

265

avatar image

Hi All,

As per requirement I need to generate XML file with some CDATA sections.

Based on the sample xml file shared I have created ABAP data structure and also created simple transformation using STRANS. Now I want to change some particular node type as CDATA section so that text with special characters are filled accordingly.

I searched through many blogs but I could not find exact solution. All I want is to change a particular node type as CDATA by modifying the source code generated by SAP through ST.

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

1 Answer

Sandra Rossi Jun 12, 2017 at 06:42 AM
0

Usually, I think we need CDATA only for the ease of manually editing or reading an XML file using a simple text editor (to not escape some of the special characters, especially the tag starting character < ). If you use a tool to generate an XML file, I don't see the need for using CDATA, as these special characters are automatically escaped (< becomes <). The only reason I can think of, is that the XML file is read by a poor program, but that would surprise me a lot.

So, I think that the transformation language doesn't need to implement CDATA.

If you need so much CDATA, then you may implement it after the transformation, by replacing a dummy unique placeholder text with your CDATA string.

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

My understanding might be off, but I always assumed CDATA was for more unstructured text data, kinda like the XML equivalent of a BLOB. e.g. the "documentation" tag generated by Eclipse BPMN. It is also handy for telling editors to keep the CR/LF intact within the CDATA contents.

0

I agree, but I think you can write it without CDATA too. I just think that CDATA is more convenient for reading those texts via a text editor. Maybe I'm wrong.

0

0

Thanks Sandra for your reply.

Here is the list of steps I did for creating Transformation.

1. Created WSDL from XSD given by the client using the sap program SPROX_XSD2WSDL.

2.Proxy structure created using WSDL.

3.Created Simple Transformation for the ABAP proxy structure created.

In the xml file many CDATA sections are available like shown below

-<element name>

<![CDATA[TEXT]]>

</element name>

But in the generated Transformation it just created the node without CDATA section, Now i need to know is there way i can change the source code of transformation to bring the CDATA section inside the element or keeping some tags in the character data to bring the following section while displaying XML ?

<![CDATA[TEXT]]>

0

If you need so much CDATA, then you may implement it after the transformation, by replacing a dummy unique placeholder text with your CDATA string.

0

Hi Sandra,

Could you please explain in detail on how to add CDATA string after CALL transformation?

Please share any code sample or procedure to do it.

Thanks

0
REPLACE 'dummyplaceholder' IN xmlstring WITH '<[CDATA[mytext]]>'.
0

Thanks for your reply.

I am new to do this call transformation could you please let me know how do you keep dummy place holder?

Also I have many element in the XML for CDATA so I need to update different text for the respective CDATA sections.

In this case I don't think replace statement can be used as it will overwrite all place holder with same text.

0