Skip to content

Instantly share code, notes, and snippets.

@kevinhooke
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinhooke/97f5142d4859287c1492 to your computer and use it in GitHub Desktop.
Save kevinhooke/97f5142d4859287c1492 to your computer and use it in GitHub Desktop.
Disable JAXP DTD loading and validation
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
dbf.setNamespaceAware(true);
//one of these pairs of properties will work depending on which xml api impl is in use
dbf.setFeature("http://xml.org/sax/features/namespaces", false);
dbf.setFeature("http://xml.org/sax/features/validation", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment