cancel
Showing results for 
Search instead for 
Did you mean: 

Creating CDATA sections in output XML

Cortex2k
Active Participant
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi,

I've got the same problem.

Could anybody explain to me the solutiion?

Thanks.

former_member235717
Participant
0 Kudos

Can you explain how you added the CDATA tags directly in the mapping?

Former Member
0 Kudos

Hi Can,

I have the same requirement where I will be receiving xml message into SAP PI and while mapping to target structure, I have add CDATA for only few fields in the output. Could you please let me know how did you achieve in your scenario and the java function details?

Thanks,

Ash

jayshukla
Explorer
0 Kudos

Hello,

Please let know the solution for this. I have generated the xml for the IDoc by right clicking and selecting return as xml. Now I need to put this entire IDoc xml in an CDATA section.

Thanks.

Jay

hsonnenahalli
Contributor
0 Kudos

Vill-

Please let me know what was the Java function which you have used to insert the CDATA tag.

Thanks

HS

former_member183908
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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;

}