[jdom-interest] Substituting a different <!DOCTYPE ...> when parsing an XML file

Elliotte Rusty Harold elharo at metalab.unc.edu
Tue Jun 4 05:37:57 PDT 2002

At 4:36 PM +0000 5/30/02, Geoff Rimmer wrote:
>When parsing XML files with validation switched on, I think that in
>95% of cases, it should be the *application* rather than the XML file
>that specifies which DTD file to validate against.

Basically I agree with you. Unfortunately, XML is designed in the 
opposite fashion. Doing what you suggest is pretty much nonconformant 
with the XML 1.0 specification. :-( The EntityResolver hack that's 
been suggested fails in the face of internal DTD subsets and 
documents with unexpected system and/or public IDs. This is a design 
flaw in XML (IMO) and is not really something that can be fixed at 
the level of JDOM.

Schemas do fix this, and explicitly allow you to validate against a 
schema of your choice which is not necessarily the one referenced by 
the document.

| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |

More information about the jdom-interest mailing list