on 06-07-2007 3:28 PM
Hi
I have created a adapter module to convert xml message to text. I used sax parser for that purpose.
Module works fine. But module starts giving problems when we give some German characters in the xml message.
It replaces corresponding German characters with a question mark.
for eg. if the value of a text node is ABÜG, this is converted as AB?G.
The xml file is encoded with "UTF-8" and below is the code fragment to parse the xml message -
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(true);
saxParser = spf.newSAXParser();
InputStream is = new ByteArrayInputStream(payload.getBytes());
InputSource iSource = new InputSource(is);
iSource.setEncoding("ISO-8859-1");
saxParser.parse(iSource, this);
if(null != is){
is.close();
}
Thanks in advance.
Abhishek,
try using CDATA section for this. There is CDATA section for parsing xml which is like an escape sequence.
Regards,
Yomesh
Message was edited by:
Yomesh P Sharma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Abhishek ,
Where are you using this module ? Sender Adapter or a receiver adapter?
If sender adapter, then in the sender adapter , change the file type as Text and make the encoding as "ISO-8859-1".
If receiver adapter, before calling the sax parser, convert the module payload to a string and then do a search and replace to convert UTF - 8 to ISO-8859-1
Regards
Bhavesh
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.