I have a DomParser in my Java class ( com.sun.org.apache.xerces.internal.parsers.DOMPars er) that I wish to fall over /exit when it detects a DTD error. However it only seems logs an error.
I have an attribute (in my XML) that defines a single data type. When I define a 'second' datatype for this attribute, in an effort to introduce a fault, the parser recognises the error but fails to stop...it just outputs the following message...
[Error] :6789:14: The content of element type "dataType" must match "(boolean|octet|char|double|float|long|longlong|sh ort|string|wstring|enumRef.... ... etc)".
I set the DomParser features as below...
How do I get the parser to exit immediately when it recognises this and similar errors?
..........
..........
..........
protected static final String DEFER_NODE_EXPANSION = "http://apache.org/xml/features/dom/defer-node-expansion";
protected static final String CONTINUE_AFTER_FATAL_ERROR = "http://apache.org/xml/features/continue-after-fatal-error";
protected static final String NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
protected static final String VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
protected static final String SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
protected static final String EXTERNAL_SCHEMA_LOCATION = "http://apache.org/xml/properties/schema/external-schemaLocation";
.........
.......
// Instantiate the parser
parser = new DOMParser();
// Set parser features for schema validation
try {
parser.setFeature(DEFER_NODE_EXPANSION, true);
parser.setFeature(CONTINUE_AFTER_FATAL_ERROR, false);
parser.setFeature(VALIDATION_FEATURE_ID, true);
parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
} catch (final SAXNotRecognizedException e) {
....
parser.parse(source);