[jdom-interest] How to get the XML Decl with JDOM?

Alex Rosen arosen at silverstream.com
Mon Nov 5 13:10:58 PST 2001


> 1. JDOM ships with a Xerces version. Is it advisable to
> upgrade that Xerces version?

JDOM should work fine with any SAX-compliant parser.

JDOM does not currently use the SAX2 extensions for anything, including
getting the XML declaration. So, someone (i.e. hopefully you) would have to
modify JDOM's SAXBuilder so that it took advantage of these extensions to
get the info out of the XML declaration and so something useful with it. Or
it might be simpler to subclass SAXBuilder and/or SAXHandler rather than
modifying the original code.

If you got this working, I would think that this would be something we'd
like to include in JDOM, but it'd be a little tricky because we'd have to
make sure it handled non-SAX-extension parsers gracefullly. E.g. if we
wanted to add Document.getEncoding(), would it be OK if it just returned
null if the parser didn't provide that info?

> 2. A particular Xerces version includes SAX packages.  Is it
> advisable to upgrade the Sax version?

No. Xerces implements the SAX interface, so changing the interface without
changing Xerces won't work.

Alex




More information about the jdom-interest mailing list