There are a number of workarounds for this. Choose the best that fits your situation.
- Remove the DTD declaration from XML file.
- Create an empty DTD file and turn off DTD validation.
- Turn off downloading of external DTDs and validation if the XML reader/parser implementation supports it. To do this for xerces, we did following:
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
// Ignore loading external DTD
dfactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
// turn-off validation which will require DTD to be present
dfactory.setFeature(”http://xml.org/sax/features/validation”, false);
Thanks to Denish for the 3rd workaround.
No comments:
Post a Comment