[jdom-interest] EntityResolver (DTD Not Found)

Brett McLaughlin brett at newInstance.com
Fri Jul 20 06:24:37 PDT 2001

> Right. The solution suggested originally is wrong. When an EntityResolver
> returns null from resolveEntity, it means "I have no clue about this
> you (the parser) try looking it up however you can" -- which usually means
> the parser will try interpreting the system id as an URL or a file, then
> give up. If you really want to provide an empty entity, you could try
> returning
>   new InputSource(new StringReader(""))
> instead of null.

Yup, I was getting ready to answer your mail, looked at my quoted reply, and
noticed a nice missing else statement. Should have been:

public class MyResolver implements EntityResolver {
   public InputSource resolveEntity (String publicId, String systemId)
     if (systemId.equals("http://www.myhost.com/today")) {
              // return a special input source
       return new InputSource(new StringReader(""));
     } else {
              // use the default behaviour
       return null;

Too much coffee that day, I guess; got send-happy ;-)

Nice catch, Attila.

Brett McLaughlin
Enhydra Strategist:   http://www.enhydra.org
Lutris Technologies: http://www.lutris.com
O'Reilly Author:       http://www.newInstance.com

More information about the jdom-interest mailing list