ISAXErrorHandler Interface

 

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

Methods

error Method
Receives notification of a recoverable error.

fatalError Method
Receives notification of a nonrecoverable error.

ignorableWarning Method
Receives notification of a warning.

Remarks

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 as follows for SAX2.

  • In Visual Basic, 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.

  • In C++, 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.

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.

Requirements

Implementation:

msxml3.dll (MSXML 3.0)

msxml6.dll (MSXML 6.0)

Header and LIB files (C/C++): msxml2.h, msxml2.lib, msxml6.h, msxml6.lib

Versioning

Implemented in: MSXML 3.0 and later