5.1.8 XML Validation

All XML services have the ability to validate XML documents using DTD and XML Schema grammars.

All XML services use the SAX2 'org.xml.sax.XMLReader' interface and validation features are enabled via this interface.

All XML services use the 'org.apache.xerces.parsers.SAXParser' parser and have the following features enabled.

Feature

Description

http://xml.org/sax/features/validation

DTD validation is enabled.

http://xml.org/sax/features/namespaces

Name space processing is enabled.

http://apache.org/xml/features/validation/dynamic

Dynamic validation is enabled.Validation is only done if the grammar is present in the document.

http://apache.org/xml/features/validation/schema

XML schema validation is disabled by default.This feature can be enabled by the use of the SCHEMA keyword or 'validation.schema' property.

The DTD grammar is specified by the DOCTYPE before the root element.

<!DOCTYPE Orders SYSTEM "order.dtd">

The XML schema grammar is specified by the xsi:schemaLocation or xsi:noNamespaceSchemaLocation attribute on the root element of the document.

The xsi prefix must be bound to the Schema document instance namespace, as specified by the recommendation.

Each document that uses XML Schema grammars must specify the location of the grammars it uses by using an xsi:schemaLocation attribute if they use namespaces, and an xsi:noNamespaceSchemaLocation attribute otherwise.

These are usually placed on the root / top-level element in the document, though they may occur on any element.