How to set non validating with DOM
843834Aug 1 2002 — edited Apr 29 2008How can I avoid validation against DTD using DOM parsing?
I want to parse XML from a stream source like a socket which includes a DOCTYPE reference.
Everything left by default settings, the DocumentBuilder.parse(InputStream is); method tries to read the DTD.
This causes an exception because the DTD file couldn't be found in current working directory.
I know that I could set the factory to non validating by DocumentBuilder.setValidating(false);
But I wonder why it's needed because the default value for this property is false.
In case of SAX parsing I've seen that people use SAXParser.setProperty(String name, Object value); to achieve non validation.
However, DocumentBuilderFactory doesn't implement setProperty(). DOMParser does but I'd like to use the proper interfaces instead cutting directly into the DOMParser.
Thanks for any hint
Carsten