Subscribe to
Posts
Comments

Xerces And DTD’s

So I have been working with Xerces and Jdom

It turns out that even when you turn off Validation the XML Parser will try to download the DTD and error out if it can not download it.

I took me quite a while to figure out how to do it.
I needed to create an EntityResolver that does nothing

The first problem I has was that if you return null the XML Parser will take it to mean that you don’t want to deal with it and you can let the XML Parser do what it normally does.

public class MyEntityResolver implements EntityResolver {

    public InputSource resolveEntity(final String publicId, final String systemId)
            throws SAXException, IOException {

            InputSource is = new InputSource(systemId);
            is.setByteStream(new ByteArrayInputStream(new byte[0]));
            return is;
    }
}

RSS feed | Trackback URI

Comments »

No comments yet.

Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong> in your comment.