cancel
Showing results for 
Search instead for 
Did you mean: 

File>XML Content Conversion: Problem with special characters

Former Member
0 Kudos

Hello,

in a file sender cc content conversion is used to transform a flat structure to XML. What we experiencecd is that the message mapping failed due to a character that was not allowed in XML:

I was assuming that the file content conversion just creates XML messages with allowed characters. Is there any way to configure content conversion to remove control characters which are not allowed in XML? Unfortunately the sender system cannot be modified.

Thank you.

Accepted Solutions (0)

Answers (4)

Answers (4)

anupam_ghosh2
Active Contributor
0 Kudos

Hi Florian,

Please use this UDF to remove special characters which prevent XML messages to form properly.


public static String removeSpecialChar(String s)
	{
		try
		{
			s=s.replaceAll("&","& amp ;");
			s=s.replaceAll("<"  , "  & lt ;");
			s=s.replaceAll(">", "& gt ;");
			s=s.replaceAll("'", "& apos ;");
			s=s.replaceAll("\"", "& quot ;");
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		return s;
	}

Please remove spaces between characters within double quotes. I have added them because otherwise you can't see this code properly. Please check this below link , please replace the characters with proper values as the display is causing a problem here

http://support.microsoft.com/kb/316063

regards

Anupam

Edited by: anupamsap on Jul 7, 2011 4:22 PM

Edited by: anupamsap on Jul 7, 2011 4:23 PM

baskar_gopalakrishnan2
Active Contributor
0 Kudos

> Is there any way to configure content conversion to remove control characters which are not allowed in XML? Unfortunately the sender system cannot be modified

Content conversion does not remove special characters. You can write simpe UDF to remove special characters in the mapping. That is the feasible option.

Use java method replaceAll or replace() to achieve this.

Refer this [link |http://www.roseindia.net/java/string-examples/string-replaceall.shtml]for sample

Former Member
0 Kudos

try to remove special characters in mapping...

Former Member
0 Kudos

Hi,

Probably you can use a java mapping to replace the control characters in mapping, as discussed in this blog-

/people/community.user/blog/2008/05/05/implementing-a-java-mapping-in-sap-pi-to-remove-escape-sequences-from-a-file

Regards,

Francis