[jdom-interest] How to get the XML Decl with JDOM?
rpcee
rpcee at operamail.com
Mon Nov 5 16:28:02 PST 2001
xerces 2 XNI allows access to the encoding - there's a SAX style callback
xmlDecl(version="1.0",encoding="UTF-8",standalone=null)
Presumably this would require an XNIBuilder, which would be xerces specific.
(reads further down the todo and notices this has already been discussed - did
anyone build such a thing?)
I didn't notice any way of reporting of whitespace after the xml decl and
before the root element.
You also get useful DTD information. I notice proper access to DTD is
mentioned in the in-memory validation todo; is the implementation of this
intended to be:
write a JDOM DTD Validator, then write a schema validator (then RELAX, ...)
Would some validation be immediate if possible - eg setText() on an EMPTY or
element content only element, setting a duplicate ID.
this seems like a lot of work. Does anyone know if there are in memory DOM
validators - eg can xerces do this?
>===== Original Message From "Alex Rosen" <arosen at silverstream.com> =====
>> 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
>
>_______________________________________________
>To control your jdom-interest membership:
>http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost
.com
More information about the jdom-interest
mailing list