XML validation is the cornerstone of good document authoring.
The key to giving meaning to an XML document -- and the crux of validation -- lies in the set of constraints that governs that document, and in ensuring that those constraints are followed.
(If a combination is not supported by a particular implementation, it is required to generate a factory configuration error.) Although a full treatment of XML Schema is beyond the scope of this tutorial, this section shows you the steps you take to validate an XML document using an existing schema written in the XML Schema language.
Listing 2 adds a class to the source shown in Listing 1 and registers that error handler with the parser.import sax. But these three methods are very helpful in letting you know exactly what the problem is and where that problem occurred.
Now that you know how to use an XML Schema definition, we'll turn to the kinds of errors you can see when the application is validating its incoming data.
To do that, you'll use a document type definition (DTD) as you experiment with validation.
For now, understand that schema validation is a namespace-oriented process.
Because JAXP-compliant parsers are not namespace-aware by default, it is necessary to set the property for schema validation to work.
As an example, the element elements are allowed (as in a lengthy novel with hundreds of pages).