Validating schema sax


validating schema sax-33

The choice of validation method depends on the additional functionality required in the validation application.

SAXParser is recommended if SAX parsing event notification is required in addition to validation with a schema.

DOMParser is recommended if the DOM tree structure of an XML document is required for random access and modification of the XML document.

In this section we shall validate the example XML document with XML schema document catalog.xsd, with the SAXParser class. Create a SAXParser object and set the validation mode of the SAXParser object to SCHEMA_VALIDATION, as shown in the following listing: Validates the complete XML document with an XML schema if the parser is able to find a schema.

An XMLSchema object represents the DOM structure of an XML schema document and is created with an XSDBuilder class object.