How the SAX Validator Application Works


[This sample application uses a feature that was first implemented in MSXML 4.0.]

This application is similar to the search and abort application in that it uses the ISAXLocator interface, which is also implemented in that application. In the SAX validator application, the location information is used to help provide exact error information when a validation error occurs during SAX parsing.

Results are reported in one of the following ways, depending on whether the XML file validates to the specified XSD schema.

  • If the file is valid, the application reports a simple acknowledgment message ("File is valid."). The SAX content handler provides this message by using code that is added to the endDocument method.

  • If the file is not valid, error text is written instead. This text describes the cause of the error. It also provides the location (by line and column number) of the error in the sample file. The SAX error handler provides this information by using code that is added to each of its member methods: error, fatalError, and ignorableWarning. These methods reference a private function, WriteErrorToResults, that is added to the MyValidator class module.

See Also

endDocument Method
ISAXErrorHandler Interface
Validate Documents Using SAX
Overview of the SAX Validator Application
Sample XML and XSD Files (SAX Validator)
Application Form (SAX Validator)
MyValidator Class (SAX Validator)
Run the Application (SAX Validator)