Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Make DocumentBuilder.parse ignore DTD references

843834May 31 2009 — edited Jun 3 2009
Thanks to everyone in advance -

So this issue looks to be pretty popular, I have found a few solutions, but nothing seems to stop the downloading of dtd files, for instance ones sitting up on w3.org.
Here are some of the solutions i have found:
http://stackoverflow.com/questions/155101/make-documentbuilder-parse-ignore-dtd-references
http://forums.sun.com/thread.jspa?threadID=284209&forumID=34

When I use this solution:
myDocumentBuilder.setEntityResolver(new EntityResolver() {
          public InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
                 throws SAXException, java.io.IOException
          {
            if (publicId.equals("--myDTDpublicID--"))
              // this deactivates the open office DTD
              return new InputSource(new ByteArrayInputStream("<?xml version='1.0' encoding='UTF-8'?>".getBytes()));
            else return null;
          }
});
it still continues to download the dtd.

Any suggestions?

Thanks,

Sam
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 1 2009
Added on May 31 2009
2 comments
288 views