cancel
Showing results for 
Search instead for 
Did you mean: 

Adapter module converting XML to text using sax parser.

Former Member
0 Kudos
90

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

I can not manipulate incoming message. It is not supporting any German character. it would be very difficult surround all those in a CDATA section.

The most surprising thing is that the same code fragment which I wrote in a test program is running fine in NWDS.

bhavesh_kantilal
Active Contributor
0 Kudos

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

Former Member
0 Kudos

I am using the module in Receiver Adapter. I already tried, that is not solving the problem.

bhavesh_kantilal
Active Contributor
0 Kudos
iSource.setEncoding("ISO-8859-1");

Sorry failed to see this.

Meanwhile, can you check the output of the mapping in MONI. Does the XML contain the valid payload? If yes, did you test the moule with this payload and did it work as expected?

Regards

Bhavesh

Former Member
0 Kudos

XML is containing the valid payload. but module is not working as expected with the that payload .