Skip to Content
avatar image
Former Member

How to add CDATA section in simple transformation

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jun 12, 2017 at 06:42 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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.