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@xxxxxxxxxx
E-mail: mrglavas@xxxxxxxxxx
Joseph Kesselman <keshlam@xxxxxxxxxx> 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@xxxxxxxxxxxxxxxxx
> For additional commands, e-mail: j-users-help@xxxxxxxxxxxxxxxxx
>
|