Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - SAX2 Reference

ISAXErrorHandler Interface

The ISAXErrorHandler/IVBSAXErrorHandler interface provides the basic interface for handling parsing errors.

Methods

error Receives notification of a recoverable error.
fatalError Receives notification of a nonrecoverable error.
ignorableWarning Receives notification of a warning.

[Visual Basic]

To implement customized error handling, the application must implement this interface and then register an instance with the SAX2 reader, using the errorHandler property. The reader then reports all errors and warnings through this interface. If an application does not register an ErrorHandler, XML parsing errors are unreported and unexpected behavior can occur.

In the original Java SAX2 implementation, all methods in this interface have only one parameter: SAXParseException. However, because exceptions are handled differently in COM, SAXException and derived classes are not implemented. Instead, the single SAXParseException parameter is replaced with the following methods for SAX2.

If an error occurs during the parse operation, the reader invokes the methods in the ErrorHandler class and passes the method the appropriate error information. In general, it's rare that you would call these methods yourself. As such, the syntax shown for the IVBSAXErrorHandler interface focuses on implementation syntax, rather than usage syntax.

Important   The SAX2 reader passes string values to IVBSAXErrorHandler methods by reference, rather than by value.
[C/C++]

To implement customized error handling, the application must implement this interface and then register an instance with the SAX2 reader using the putErrorHandler method. The reader then reports all errors and warnings through this interface. If an application does not register an ErrorHandler, XML parsing errors are unreported and unexpected behavior can occur.

In the original Java SAX2 implementation, all methods in this interface have only one parameter: SAXParserException. However, because exceptions are handled differently in COM, SAXException and derived classes are not implemented. For this reason the single SAXParserException parameter is replaced with the following input parameters.

[in] ISAXLocator * pLocator
The Locator object, which contains line and column numbers of the error. SystemID and PublicID may be unavailable for particular data sources, such as character buffer.
[in] const wchar_t * pwchErrorMessage
The property inherited from the class, org.xml.sax.SAXException. In a COM implementation, provides error information.
[in] HRESULT hrErrorCode
The HRESULT code for the reason of the error.
All these methods can return either S_OK code (which matches the Java 'void xyz()' and still aborts parsing for fatal errors), or E_FAIL (which matches throwing a Java exception) and means that parsing should be aborted no matter what level.

Versioning

MSXML 3.0 and later

Requirements

Implementation: msxml5.dll

[C/C++]

Header and LIB files: msxml2.h, msxml2.lib

Remarks

When you use SAX validation, error events are thrown when content is invalid according to the XSD schema used for validation. If the "exhaustive-errors" feature on the SAX reader is set to False (the default), the reader ignores the return value for the error and aborts parsing. If the "exhaustive-errors" feature on the SAX reader is set to True, parsing can continue if S_OK is returned in an error event.

To view reference information for Visual Basic or C/C++ only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

errorHandler Property (Visual Basic) | putErrorHandler Method (C/C++)