You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Brett McLaughlin <br...@earthlink.net> on 2000/04/12 02:06:27 UTC

Validation in DOMParser

I must be really missing the boat here.  If I have this code:

try {
    DOMParser parser = new DOMParser();
    parser.setFeature("http://xml.org/sax/features/validation", true);
    parser.parse(new InputSource(in));
    Document doc = parser.getDocument();
} catch (Exception e) {
    e.printStackTrace();
}

and invoke it where in is a FileInputStream wrapping a local XML
document, which specifies a DTD that makes the document invalid, I get
absolutely no exceptions.  I can parse the same document with a SAX
Parser with validation on (and a registered ErrorHandler that gripes on
the error() callback), I get errors.  So why isn't validation for the
DOMParser letting me know something is invalid?

Thanks,
Brett