users@jaxb.java.net

Re: error handling using jaxb

From: Raymond Wold <raymond.wold_at_teletopia.com>
Date: Fri, 28 Sep 2007 08:21:37 +0200

kal stevens wrote:
> I want to use jaxb to parse an xml file which apparently has bad data.
>
> Specifically it can have invalid utf8 characters.
>
> Is there any documentation on how to do error handling using jaxb?
>
> Specifically my error is:
> org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x1a) was
> found in the value of attribute "name" and element is "product".
>

Chances are the XML file is encoded with something other than UTF-8, and need
to have the proper character encoding set in the file.

If it really is an error, you should not try to parse it. This is an
ideological stand, as XML is only useful as long as parsers behave the same,
according to the standard. Once you go into error correction, parsers will
diverge, and document authors will start to write for parsers instead of for
the standard. Fix the document at the source, get a valid XML document from
whomever provided it to you.