Showing results for 
Search instead for 
Did you mean: 

XI30: Escape characters codes on message mappings

Former Member
0 Kudos


I have to generate and send an xml file (encoding utf-8)that contains escape characters code.

I mean, I need to put for example § instead of '§' or ~ instead of ~.

Let suppose XI receives an xml that contains these strange characters and let suppose that XI have to change them (in string fields obviously) into their corresponding codes.

I made in the message mapping an user-defined function like this:


StringBuffer sb = new StringBuffer();

int n = a.length();

for (int i = 0; i and it does not convert properly the entire code.

So, the displayed result on xml-target is not what I expected to see (§ ???).

Is there anyone of you, guys, that knows a trick to bypass this problem and finally generate an xml target file containing escape characters codes?

thanks in advance


Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Alex,

Try using this method:

<b> arg)</b>



Former Member
0 Kudos

Hi Ananth,

I tried the solution you proposed but it's not what I want to do.

I tried to follow other ways (inside the message mappingbut, in any case, my pretty friend XI convert two times '&'.

XI doesn't work properly even if I put my node value inside a CDATA.

I suppose I must find "something" out from the graphical mapping.

Is there anyone else having other suggestions?

I'll appreciate so much.

tnx friends.


Former Member
0 Kudos

Alex ,

this is the code I always use in my Java mappings to replace < > & and ' at one go. May be you'll get a hint from this.

String currentData = new String(ch, start, length);
currentData =currentData
	.replaceAll("&", "&amp;")
	.replaceAll("<", "&lt;")
	.replaceAll(">", "&gt;")
	.replaceAll("'", "&apos;");

Former Member
0 Kudos

Hi Amol,

if I had an XI environment that works properly, I suppose, your solution should be OK.

As I ready tested a similar trick biy using a java mapping, I tell you that the result is:

<myTargetNode>text &amp;lt</myTargetNode>

instead of

<myTargetNode>text &lt</myTargetNode>

Very strange, isn't it?!?

Former Member
0 Kudos


It is clear from your output that your replace logic is getting called like this :

<b><myTargetNode>text ></myTargetNode></b>gets converted to

<b><myTargetNode>text &lt;</myTargetNode></b>and once again the next part which replaces the & in this too

so your output is then

<b><myTargetNode>text &amp;lt;</myTargetNode></b>

May be you could try with a proper replace sequence in this case ...

Former Member
0 Kudos

Hi Amol,

even with a proper doesn't work.

I tried to do another kind of solution:

The Sender system sends an xml that already contains escape codes. I thought it was a good idea. So, I suppressed all replaces, 'cause they were useless.

Well, do you want to know what Xi has made?

Watch the example here below:


I have seen into Communication Channel section (ID)

there is a parameter I can use: an option flag on "Mask Special Characters (URL escaping).

Is it possible that if I choose it, the receiving system receives an xml with escape chars?

Active Contributor
0 Kudos


Hmmm thats a problem. What I will suggest is to write a jave module (for the receiver) which will replace the symbol with the appropriate code. Try this.



Former Member
0 Kudos

Hi Suraj,

I 'm using a HTTP receiver, so I can't use a java module to link to the Communication Channel. HTTP is on ABAP stack.

Anyway, I cannot change the adapter type for the receiving system: the owner doesn't allow to do this.

In few words, I have bounded hands and I have to find a solution without changing the scenario:


I'm going to write an OSS Note 'cause I really don't know what to do.

Perhaps it's useful for you to know "how to do" in these cases: I will update this discussion with solutions proposed by SAP.

Regards and many thanks for your support