commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: [Digester] How to turn off parse's attempt to retrieve dtd?
Date Wed, 15 Jun 2005 08:31:42 GMT
Hi Jon,

On Wed, 2005-06-15 at 03:36 -0400, Jon Steelman wrote:
> When I parse after setValidating(false), why does Digester still try to
> retrieve the dtd file? What else do I need to set in Digester to make it
> ignore xml like <!DOCTYPE cardActionVendor SYSTEM
> "cardActionVendor.dtd"> ? Otherwise, I cannot parse and if I don't have
> the dtd at the moment and always get the
> (The system cannot find the file specified). Using Digester 1.7.

This is standard XML parser behaviour. Even when validation is disabled,
an XML parser still needs the DTD for things such as entity definitions.

Digester provides basic support for using local copies of resources
referenced from an xml file (such as DTDs): if your DOCTYPE declaration
was properly formed (ie had a PUBLIC declaration instead of just a
SYSTEM declaration) then you could have used the Digester.register
method to register a local copy of the DTD for the PUBLIC id. Note that
omitting the PUBLIC id from a DTD decl is WRONG in any application where
xml is expected to be used on a host other than the one it is created

But as you've got a broken DOCTYPE you have two options:
(1) use some parser-specific property setting to tell the parser to
ignore external DTDs. If you're using Sun's java 1.4 or later then the
underlying parser is actually Xerces, so see
  for feature external-parameter-entities
and see also method Digester.setProperty. Of course this isn't terribly
portable, nor guaranteed to work in future JVMs (though I can't see Sun
ditching Xerces for anything else in the near future).

(2) write a custom EntityResolver subclass that returns an empty stream
when asked for the DTD, and register that with Digester using



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message