Loading

Tag Archives: load

Disable DOM DTD validation

setValidating(false) will not prevent DTD validation, but you can set http://apache.org/xml/features/nonvalidating/load-external-dtd feature to false. I think is a Xerces-only feature, though, it may not be recognized by other parsers. DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); //factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); // it doesn’t work factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); DocumentBuilder parser = factory.newDocumentBuilder(); Document doc = parser.parse(getClass().getResourceAsStream("ennote.xml")); Typical DTD not found exception [...]