Overview of the SAX Validator Application

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - SAX2 Developer's Guide

Overview of the SAX Validator Application

The SAX validator application uses the following SAX interfaces.

SAXXMLReader
A CoClass that implements the ISAXXMLReader interface. The SAX reader parses the XML and throws events to the handlers that you set for the reader. This application creates an instance of SAXXMLReader, enables SAX validation by setting the schema-validation feature, and sets the schema and schema-declaration-handler properties on the reader to fully enable support for SAX-based validation.
XMLSchemaCache
For this application, you declare the XMLSchemaCache object and add the schema file (in this example, books.xsd) to it as a member. The XMLSchemaCache object is then assigned to the SAX reader to be used to validate the sample XML file (books.xml).
IVBSAXContentHandler
Provides content handling features. For this application, the MyValidator class implements this interface to receive content events that are thrown by the SAX reader. For this application, the content handler uses only a single event, the endDocument method, to acknowledge a successful validation of the file.
IVBSAXErrorHandler
Provides error handling features. For this application, the MyValidator class implements this interface to receive errors that are thrown by the SAX reader.
IVBSAXLocator
Provides location information. For this application, the MyValidator class implements this interface and uses its lineNumber and columnNumber properties to return the position within the XML file as part of error reporting if a validation error occurs.

This application consists of the following two main parts.

Application form
A Microsoft® Visual Basic® 6.0 form that provides the user interface for the application. This form consists of three text boxes with corresponding labels. Two of the text boxes are used to enter file and path information for the XML and XSD files that are used as input. The third text box displays the output of the application.

The form also has two command buttons: Validate and Exit. Pressing Validate starts application processing. Pressing Exit unloads the application form, effectively exiting the application.

MyValidator
A Visual Basic class module that implements the IVBSAXContentHandler, IVBSAXErrorHandler, and IVBSAXLocator interfaces. When SAX parsing begins, the SAX reader throws a series of events that are received by an instance of this class.

See Also

Validate Documents Using SAX | Overview of the SAX Validator Application | Application Form (SAX Validator) | Sample XSD Schema File (SAX Validator) | MyValidator Class (SAX Validator) | Run the Application (SAX Validator) | How the SAX Validator Application Works