You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Vipul Sabhaya <vi...@hubspan.com> on 2006/01/18 21:13:18 UTC

Validate without DOCTYPE

I have a input xml document without a DOCTYPE declaration.  The DTD to
validate this document is preconfigured and known.  How can I force
validation by specifying the DTD, when the input xml does not contain
the DOCTYPE?

Thanks.


Re: Validate without DOCTYPE

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
There is a more elegant solution if you're using Xerces 2.7.x. SAX 2.0.2 
added an extension interface called EntityResolver2 [1] which allows 
applications to provide an external subset to documents which do not have 
one. This includes documents which have no DOCTYPE declaration. If an 
instance of EntityResolver2 is registered with the SAX parser 
getExternalSubset() will be called in such cases. The same applies to 
DocumentBuilders.

[1] 
http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/ext/EntityResolver2.html

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

Joseph Kesselman <ke...@us.ibm.com> wrote on 01/18/2006 04:03:37 PM:

> The usual/simplest solution is to set up a filtering stream wrapper 
which
> prepends the appropriate doctype declaration if one isn't provided in 
the
> file, and parse from that. This may not be elegant, but it's simple and 
it
> works.
> 
> ______________________________________
> Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
> "The world changed profoundly and unpredictably the day Tim Berners Lee
> got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-users-help@xerces.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org


Re: Validate without DOCTYPE

Posted by Joseph Kesselman <ke...@us.ibm.com>.
The usual/simplest solution is to set up a filtering stream wrapper which
prepends the appropriate doctype declaration if one isn't provided in the
file, and parse from that. This may not be elegant, but it's simple and it
works.

______________________________________
Joe Kesselman, IBM Next-Generation Web Technologies: XML, XSL and more.
"The world changed profoundly and unpredictably the day Tim Berners Lee
got bitten by a radioactive spider." -- Rafe Culpin, in r.m.filk


---------------------------------------------------------------------
To unsubscribe, e-mail: j-users-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-users-help@xerces.apache.org