RE: Problem parsing XML

"Yuval Oren" <[email protected]> Mon, 9 Jun 2003 07:48:02 -0700
Newsgroups gmane.text.xml.sax.general
Message-ID <[email protected]>
I think your problem is that Java is not recognizing the payload as unicode.
Strings are already supposed to be decoded into characters, so you are
getting 1 character per byte instead of 1 per 2 bytes. Try getting a binary
input stream instead (HttpServletRequest.getInputStream()). Remember that
the first character you pass to the parser has to be either the byte order
mark or the '<' from '<?xml...'.

-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of Sunil Negi
Sent: Monday, June 09, 2003 5:25 AM
To: Sax-Users
Subject: [Sax-users] Problem parsing XML


hi all, I have a problem trying to parse XML strings that
are unicode. My application is a java servlet that accepts
a string [in unicode] as payload of a Post request.
My problem is that when I try to parse the XML, it throws
an invalid character Exception. This is obvious since the first char
it comes across is 0x0, which is invalid.. This is the exception..

Illegal XML character:  &#x0;.
        at
org.apache.crimson.parser.InputEntity.fatal(InputEntity.java:1038)
        at org.apache.crimson.parser.InputEntity.getc(InputEntity.java:360)
        at org.apache.crimson.parser.Parser2.getc(Parser2.java:2862)
        at
org.apache.crimson.parser.Parser2.maybeGetNameCacheEntry(Parser2.java:619)
        at org.apache.crimson.parser.Parser2.maybeElement(Parser2.java:1288)
        at org.apache.crimson.parser.Parser2.parseInternal(Parser2.java:499)
        at org.apache.crimson.parser.Parser2.parse(Parser2.java:304)
        at
org.apache.crimson.parser.XMLReaderImpl.parse(XMLReaderImpl.java:433)
        at
org.apache.crimson.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:1
79)

My problem is , how do i make the Parser recognise unicode boundaries,
rather then byte boundaries.

i m not getting headway even after using the java.nio utilities for unicode
conversion.

regards,
w|536uy




-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
List: [email protected]
See:  http://www.saxproject.org
https://lists.sourceforge.net/lists/listinfo/sax-users



-------------------------------------------------------
This SF.net email is sponsored by:  Etnus, makers of TotalView, The best
thread debugger on the planet. Designed with thread debugging features
you've never dreamed of, try TotalView 6 free at www.etnus.com.
_______________________________________________
List: [email protected]
See:  http://www.saxproject.org
https://lists.sourceforge.net/lists/listinfo/sax-users