What's the result of having a DTD validator or XML Schema validator in the pipeline?
If a validator is included in the pipeline, the assessment is done, whether the validation feature is set to true or false. The validation feature only enables the validation constraint error reporting and it does not control the infoset augmentation: if a validator is included in the pipeline the parser will augment the infoset according to the grammar specified for the instance document.
What validation behavior do I expect from the default parser configuration?
The default configuration (&DefaultConfigLong;) includes the DTD validator and the document scanner (which are both capable of namespace binding). Thus, the validation feature will enable validation against a DTD only. To allow validation against XML Schemas you must turn on the validation feature and the schema feature, and XML Schema Validator will be inserted in the pipeline. if you've created your own configuration which does not extend &DefaultConfig; (or another suitable configuration included with the parser), you must make sure that your configuration inserts all needed validators in the pipeline.
What happens if I set both validation and schema validation features on?
If both validators are present in the pipeline (this is the default behavior), then
An application may choose to create a configuration that does not have a DTD validator but has an XML Schema validator. This will turn Xerces into a non-compliant processor according to XML 1.0 and XML Schema specifications, thus the validation/augmentation outcome is undefined.
How can I tell the parser to validate against XML Schema and not to report DTD validation errors?
Using JAXP you can instruct the parser to validate against XML Schema only. The JAXP 1.4 Validation API allows you to build an in-memory representation of an XML Schema which you can then set on a parser factory. Parsers created from the factory will validate documents using the schema object you specified.
By doing the following you can configure a SAX parser or DocumentBuilder to validate against XML Schema only:
Another option is to use the JAXP schema language property defined by JAXP 1.2. If the schema
language property has been set to http://www.w3.org/2001/XMLSchema
and the parser has been configured to validate then your documents will be validated against
XML Schema only, even if they have a DTD.
By doing the following you can configure a SAX parser to validate against XML Schema only:
For a DocumentBuilder this can be accomplished by doing the following: