Xerces And DTD’s
June 21st, 2005 by Matt
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;
}
}
No comments yet.