ISAXLexicalHandler Interface

 

The ISAXLexicalHandler/IVBSAXLexicalHandler interface enables a Simple API for XML (SAX2) application to implement an optional extension handler for receiving information from the SAX2 reader, such as comments, the document type declaration, CDATA sections, and the start and end of an entity within a document. The events in the LexicalHandler apply to the entire document, not just to the document elements. All LexicalHandler events must appear between the startDocument and endDocument events of the ContentHandler.

To set the LexicalHandler for the reader, use the putProperty method with the property ID "http://xml.org/sax/properties/lexical-handler".

Methods

comment Receives XML comments from either inside or outside the document element, including comments in the external document type definition (DTD) or schema subset.
endCDATA Receives the end of a character data (CDATA) section.
startCDATA Receives the beginning of a CDATA section.
endDTD Receives the end of a document type declaration.
startDTD Receives the beginning of a document type declaration.
endEntity Indicates that the reader has opened and finished processing an externally defined entity in the content of the document.
startEntity Indicates that the reader has opened and started to process an internally or externally defined entity in the content of the document.

The IVBSAXLexicalHandler interface includes a series of methods that are invoked by the reader during the parsing operation. The reader passes the appropriate information to the method's parameters. To perform processing for a method, you simply add code to the method in the LexicalHandler implementation. In general, it's rare that you would call these methods yourself from within the LexicalHandler. The syntax shown for the IVBSAXLexicalHandler interface focuses on implementation rather than usage.

Important

The SAX2 reader passes string values to IVBSAXContentHandler methods by reference, rather than by value.

The code to register the LexicalHandler may look like the following.

... SAXXMLReader * r = ...
SAXLexicalHandler * lh = new SAXLexicalHandler ();
r->putProperty("http://xml.org/sax/properties/lexical-handler",_variant_t(lh));

Requirements

Implementation:

msxml3.dll (MSXML 3.0)

msxml6.dll (MSXML 6.0)

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

Versioning

Implemented in: MSXML 3.0 and later

See Also

endDocument Method
putProperty Method
startDocument Method