Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Problem with Xerces/XOMHandler.inInternalSubset reading from File but not FileReader or FileInputStream

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Rusty Harold <elharo AT ibiblio.org>
  • To: XOM API for Processing XML with Java <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Problem with Xerces/XOMHandler.inInternalSubset reading from File but not FileReader or FileInputStream
  • Date: Mon, 14 Sep 2009 14:55:46 -0400

On Mon, Sep 14, 2009 at 2:37 PM, Peter Murray-Rust <pm286 AT cam.ac.uk> wrote:
> We have the following code which produces runtime errors on some machines
> but not others. We are using xom-1.2.3 and Java 1.6.0_13-b03
>
>        Document doc = new Builder().build(new FileReader("b511922g.xml"));
>        System.out.println("worked with filereader");
>

This may or may not be related to your problem, but the first thing
that jumps out at me is that you should never, never use FileReader
for anything at all, and especially not for XML.

FileReader ignores character encoding information, and blithely
assumes that the local box's default character encoding is correct.
Sometimes it is. Sometimes it isn't.

The XML parser can deduce the correct encoding from an input stream,
but not from a reader.

--
Elliotte Rusty Harold
elharo AT ibiblio.org




Archive powered by MHonArc 2.6.24.

Top of Page