commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: [Digester] Error "Document root element is missing" for files with BOM
Date Fri, 11 Mar 2005 09:37:53 GMT
Hi Stefan,

On Fri, 2005-03-11 at 10:27 +0100, Stefan Burkard wrote:
> hi there
> today i encountered a problem with an xml-to-object transformation with 
> digester.
> i get an exception saying "Document root element is missing"
> as soon as i changed the problematic files to "no BOM", they were 
> imported fine by digester.

16-bit unicode text (ie data where two adjacent bytes indicate character
#0000 through #FFFF from the unicode character set) can be stored
most-significant-byte-first (MSB) or least-significant-byte-first (LSB).
The byte-order-mark is a sequence of bytes at the start of a UTF-16
document that indicates whether MSB or LSB is used to store the
character codes. [that's a rough description].

Digester doesn't bother itself with that sort of detail; that's the xml
parser's responsibility. 

So the short answer is: make sure the xml parser that digester is using
is correctly configured to handle whatever input you're feeding into it.

If you still want Digester to create the xml parser instance, then call
  Digester digester = new Digester();
  XMLReader xmlReader = Digester.getXMLReader();
  // now configure the xmlReader as appropriate

Alternatively, create the xml parser yourself:
  // create the xml parser however you want
  // configure the xml parser however you want
  Digester digester = new Digester(parser);

The exception being thrown is actually generated by the underlying
parser; Digester is just forwarding it on.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message