Skip to Content

Creating CDATA sections in output XML

Hi XI/PI Experts

Hope you are able to help me out in this matter, as I´m starting to loose my hair over this problem 😊

I have a mapping from a ARTMAS04 idoc to a XML, which works fine. The problem is that the receiver application of the XML requires CDATA sections for two of the fields in the output structure.

If I just add the CDATA tags directly in my message mapping, XI will convert the output source such as the CDATA start "<![CDATA[", is represented as "&lt;![CDATA[". I guess this is because the fields are beeing represented as Strings.

To overcome this problem I created a JAVA mapping which takes the output from my MM and add CDATA sections to the two fields using the Dom4J class. The solution works fine when I am testing it in my Interface Mapping, but when I view the source on the XML in SXMB_MONI, it still looks like "&lt;![CDATA["

How can I keep the CDATA sections without XI translating them?

Any answer is appreciated.

Best regards

Chris

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 29, 2008 at 02:44 AM

    This UDF will help you...

    //write your code here

    StringBuffer result=new StringBuffer();

    char[] splChar= {'!','#','$','%','&','<','>'};

    int length=splChar.length;

    int splCharFound=0;

    int i;

    for(i=0;i<length;i++)

    {

    if(input.indexOf(splChar<i>)!=-1)

    { splCharFound=1;

    break; // the control comes out even if ther is one Spl Charr

    }

    }

    if(splCharFound==1) //if the String contains Special Characters

    {

    result.append("<![CDATA[");

    result.append(input);

    result.append("]]>");

    return result.toString();

    }

    else //if the input doesnt contain any spl character

    {

    return input;

    }

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Apr 19, 2010 at 09:33 AM

    Hi mates, this problem it's now solved, i forgot to xplain the solution. The solution has been a java function in the mapping to split each field whit the according data structure, if u need more info, please, contact whit this forum.

    Best regards and thanks.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi ,

      Will you please let me know what function did you use to replace encoded chanracters "&lt;".I dont find this in SXMB_MONI or chanel monitoing until unless i open with notepad or viewsource.I just used constant in my mapping and concat to achive the CDATA structure.Please let me know how did u fix this issue.I tried with intermediate mapping and UDF and replace string however in the mapping results when i open using 'src' button i can see &lt; but not with normal tabular tree view.Your suggestion will be appreciated.

      Thanks

      Pawan

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.