You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by Wong Kok Wai <wo...@pacific.net.sg> on 2000/02/29 17:01:50 UTC

Re: Validating against a different DTD

You can write a class that implements org.xml.sax.EntityResolver and returns
an InputSource that "points" to your local DTD copies. Pass this object to
the SAX parser using setEntityResolver.

Elliotte Rusty Harold wrote:

> Is there any way in Xerces I can easily choose a specific DTD/schema to
> validate documents against from within the parser?
>


Re: Validating against a different DTD

Posted by Elliotte Rusty Harold <el...@metalab.unc.edu>.
>Elliotte Rusty Harold wrote:
>
> > Is there any way in Xerces I can easily choose a specific DTD/schema to
> > validate documents against from within the parser?
> >
At 12:01 AM +0800 3/1/00, Wong Kok Wai wrote:

>You can write a class that implements org.xml.sax.EntityResolver and returns
>an InputSource that "points" to your local DTD copies. Pass this object to
>the SAX parser using setEntityResolver.


This seems to work provided the document in question has a document 
type declaration with a system or public ID so that the 
resolveEntity() method will be called. What if the document only has 
an internal DTD subset, however? Or what if it has no DOCTYPE 
declaration at all? If I understand this correctly, then no DTD will 
be used. Is there a way I can specify DTDs for those case?


+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo@metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|                  The XML Bible (IDG Books, 1999)                   |
|              http://metalab.unc.edu/xml/books/bible/               |
|   http://www.amazon.com/exec/obidos/ISBN=0764532367/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ |
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |
+----------------------------------+---------------------------------+