[jdom-interest] Can't get SAXBuilder to ignore DOCTYPE

Brett McLaughlin brett.mclaughlin at lutris.com
Wed Oct 11 07:34:24 PDT 2000

Dino Fancellu wrote:
> I have an XML file with a DOCTYPE like this:
> <!DOCTYPE proposal SYSTEM
> "http://www.pensionsbusiness.com/dtd/propack_11.dtd">
> Now, I want the builder to ignore the dtd, i.e. do not validate.
> I create my builder, thus:
> SAXBuilder builder = new SAXBuilder(false);
> But I get errors from the builder/parser when I'm not online:
> org.jdom.JDOMException: www.pensionsbusiness.com: www.pensionsbusiness.com
>         at org.jdom.input.SAXBuilder.build(SAXBuilder.java:320)
>         at org.jdom.input.SAXBuilder.build(SAXBuilder.java:373)
>         at org.jdom.input.SAXBuilder.build(SAXBuilder.java:354)
>         at playpen.testxml.main(testxml.java:40)
> Root cause: java.net.UnknownHostException: www.pensionsbusiness.com
>  [stuff deleted]
>         at org.jdom.input.SAXBuilder.build(SAXBuilder.java:302)
> Basically, it (Xerces) can't find the URL, which is fair enough, but I was
> hoping that it wouldn't even look,
> as I don't want validation.

Xerces currently will parse a DTD even when validation is off; it just
doesn't use the information obtained from the DTD parsing. I'm not
really sure what other parsers do now (I've lost touch in the past month
;-) ), so this may not be common. But it's a Xerces thing,
unfortunately. What you want to do to avoid this is have a custom
EntityResolver set up on SAXBuilder which resolves that system ID
locally - check out http://www.megginson.com/SAX for details on using an
EntityResolver, and then use the setEntityResolver() method on


> What am I doing wrong? I'm no XML expert, I'd just like to be able to ignore
> validation and I thought SAXBuilder(false)
> would do that for me.
> Thanks for any help.
> Dino.
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 

More information about the jdom-interest mailing list