cancel
Showing results for 
Search instead for 
Did you mean: 

Handling special "&" in Java mapping

abhay_rajhans2
Contributor
0 Kudos

Hi Expert,

The scenario is IDoc to Text file (PI 7.0) and having two mappings

1) Graphical Mapping

2) Java Mapping

The output of graphical mapping is properly passing & in view source I can can see value as & but the output of

Java mapping is not proper.In interface mapping test tab it is throwing error that XML can not be correctly formed.

And in output payload it is throwing error "Whitespace is not allowed at this location. Error processing resource".

No special operation is done on "&" in JAVA mapping. The code page is of UTF-8. I cannot remove & as it is mandatory in output.

Please suggest.

Thanks in Advance

Regards

Abhay Rajhans

Accepted Solutions (1)

Accepted Solutions (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

In addition to above experts replies, if you want to change in java mapping use replaceAll string method to achieve this. You can read each line and save it in string and call the replace method as below

str.replaceAll("&", "&amp");

http://www.javamex.com/tutorials/regular_expressions/search_replace.shtml

Answers (3)

Answers (3)

rajasekhar_reddy14
Active Contributor
0 Kudos

Message mapping handles & internally but you have to do it manually in JAVA Mapping because GUI Mapping output is having &amp.

Baskar already provided the trick implement it.

Former Member
0 Kudos

Hi.

The character "&" is not valid for your XML. You need to change this character as "&" in your output.

Regards

Lucho


MichalKrawczyk
Active Contributor
0 Kudos

Hi,

>>>Whitespace is not allowed at this location

this error apperas when you have & only (not escaped with &amp) so the program is trying to find something after & and it finds whitespace... which is wrong - please make sure that you have &amp in both mappings and everything will be ok

Regards,

Michal Krawczyk