Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

CDATA XML Tags - Special Char

Hi Experts,

I am working on interface where in i have to send CDATA XML tag in Target structure, I have checked their are couple of discussions about the requirement but not very helpful for my case.

My Scenario :

Expected :

SOURCE TextH( TextC ) ---------TARGET <TextH> <![CDATA[TextC]]><TextH>

Currently :


SOURCE TextH( TextC ) --------- TARGET <TextH>&lt;![CDATA[TextC]]&gt;<TextH>

So instead of < and > this characters are getting replaced with  &lt;  and &gt;

Any solution how can i avoid this transformation of special characters when sending to Target

Thanks in Advance,

Regards,

Pooja

Tags:
Former Member
Former Member replied

Please try

package com.map;     

import java.io.*;     

import com.sap.aii.mapping.api.*;     

public class Test_JavaMapping extends AbstractTransformation {     

    @Override     

    public void transform(TransformationInput transformationInput, TransformationOutput transformationOutput) throws StreamTransformationException {     

        try {     

            InputStream inputstream = transformationInput.getInputPayload().getInputStream();     

            OutputStream outputstream = transformationOutput.getOutputPayload().getOutputStream();     

            // Copy Input content to Output content     

            byte[] b = new byte[inputstream.available()];     

            inputstream.read(b);     

                            

            String input = new String(b);

            String output = input.replace("&lt;![CDATA[", "<![CDATA[").replace("]]&gt;", "]]>");

            outputstream.write(output.getBytes());                

        } catch (Exception exception) {     

            getTrace().addDebugMessage(exception.getMessage());     

            throw new StreamTransformationException(exception.toString());     

        }     

    }     

}     

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question