SaxParseException mapping from column/line number

Discussion in 'XML' started by KN, Nov 22, 2007.

  1. KN

    KN Guest

    Am have a problem with a SAX parser - but am attempting to recover by
    proe-processing
    the input byte array after each exception - am parsing using the code
    below ...

    org.apache.commons.httpclient.HttpMethod method = new
    GetMethod("http://someurl");

    org.apache.commons.httpclient.HttpClient client = new HttpClient();
    int status = client.executeMethod(method);


    final byte[] responseBody = method.getResponseBody();

    com.sun.org.apache.xerces.internal.parsers.DOMParser domParser = new
    DOMParser()
    domParser.parse(new InputSource(new
    ByteArrayInputStream(responseBody)));


    - which gives me a SaxParseExceptions with the message
    "Invalid byte 2 of 3-byte UTF-8 sequence"

    and also gives me the row & column the error occurred. I am totally
    confused by this
    as there seems to be no way of mapping this to the original input
    byte[]. The only way of
    so is to write the array to disc and access the file. Does anyone
    have ay other ideas ?

    Regards
     
    KN, Nov 22, 2007
    #1
    1. Advertising

  2. KN wrote:
    > "Invalid byte 2 of 3-byte UTF-8 sequence"


    UTF-8 "characters" can be up to three bytes long, to handle the full
    Unicode range. Something in your file is not legal UTF-8. Either tell
    the system what encoding your file was actually written in, or fix the
    file so it's legal UTF-8.

    The troublesome sequence will be something involving bytes over
    the ASCII range (ie, bytes with their high bit set). Scanning for that
    may be the fastest way to find the problem.

    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Nov 23, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Angela Stempfel

    SAXParseException

    Angela Stempfel, Oct 22, 2003, in forum: Java
    Replies:
    2
    Views:
    15,486
    Chris Riesbeck
    Oct 22, 2003
  2. Marc Jordant

    SAXParseException in JSP

    Marc Jordant, Apr 7, 2004, in forum: Java
    Replies:
    0
    Views:
    708
    Marc Jordant
    Apr 7, 2004
  3. Nick
    Replies:
    0
    Views:
    3,235
  4. Marcin Cenkier
    Replies:
    2
    Views:
    6,314
    Marcin Cenkier
    Jan 19, 2006
  5. Replies:
    4
    Views:
    671
    Diez B. Roggisch
    Mar 27, 2007
Loading...

Share This Page