cancel
Showing results for 
Search instead for 
Did you mean: 

Java Mapping Parsing Error

Former Member
0 Kudos

Hi All,

I had used java mapping class in my scenario. this class parses the IDoc XML that is coming out of R/3. The IDoc XML contains a tag after 'Bef' is the root cause of the problem. the parser works fine when i remove this charecter and is failing when the charecter exists. The IDoc XML uses the encoding UTF-8. but this charecter doesn't seem to be a valid UTF-8 charecter. And i don't have a chance to modify this xml b4 parsing. I will get IDocs which contain these kind of charecters a lot. How shud i overcome this problem. any help wud b appreciated.

Thnx in Adv

Anil

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Anil Kumar,

Please let us know which XML parsing API u are using during JAva mapping.

additionaly you can use reffer to link

I think what you can do is to replace encoding of the XML before it is given to an XML parser. for that you can use replace funcationality of string.

Former Member
0 Kudos

Hi Divyakumar,

Thnx for the response. The parser works fine if i use the encoding technique ISO-8859-1 instead of UTF-8. but the problem is that i'm recieving the IDoc XML from R/3 thru an input stream. and i can't c any method that can replace a string in the input stream. i tried creating a file and reading all the input from the input stram into the same file.but the problem is that while creating a file object, it is asking me the path where it shud get created? i can't give any path coz the mapping gets executed on XI server. how shud i acheive that?

Thnx in Adv

Anil

bhavesh_kantilal
Active Contributor
0 Kudos

just do this anil.

before parsing your inputstream, do a <b>search and replace </b> in your input stream over <xml version="1.0" encoding=".... " > with whatever you want and then do the parsing.

should solve your problem.

regards,

bhavesh

Former Member
0 Kudos

Hi Anil,

Nice to hear that change in encodeing worked.

Now before giving stream to xml parser wrtie following code

<b>BufferedInputStream stream = new BufferedInputStream();

String xmlString = new String(stream.read());

String newString = xmlString.replaceFirst("UTF-8","ISO-8859-1");

ByteArrayInputStream inputStream = new ByteArrayInputStream (newString.getBytes());

</b>

now you can use this inputStream for Parsing

Former Member
0 Kudos

Hi Divyakumar,

Sorrry no luck...any further assistance please.

Thnx in Adv

Anil