Compartilhar via


Overview of the JumpStart Application (C++)

 

The Simple API for XML (SAX2) is a push-model parser. When SAX2 parses a document, the SAXXMLReader (reader) reads the document and passes a series of events to the event handlers that you implement. The SAX2 reader generates several categories of events, including:

  • Those that occur in the content of an XML document.

  • Those that occur in the document type definition (DTD).

  • Those that occur as errors.

To handle such events, you implement a corresponding handler class that contains methods to process the appropriate events. You implement handlers only for those events you wish to process. If you do not implement a handler for a specific type of event, the reader simply ignores that event.

You implement two main components in this JumpStart application.

Component Description
ContentHandler Implements the ISAXContentHandler interface. The ContentHandler is a class that provides methods for processing the main content of an XML document. When SAX2 parses a document, the reader passes a series of events to the ContentHandler. For example, for each element in a document, the reader passes startElement, characters, and endElement events. You handle these events by adding code to the methods in the ContentHandler to process the information passed by the reader.
main program - Creates an instance of ISAXXMLReader (reader).
- Creates an instance of the ContentHandler.
- Sets the ContentHandler to the reader.
- Sets the source for the XML document.
- Starts the parsing process.

To create the JumpStart application, you must first implement a handler class extending the ISAXContentHandler interface. With C++, you can create a class and not a full-featured COM object. In the methods of this class, you tell the application what to do when it receives notification of an event. After you implement the ContentHandler class, you create the main program that creates an instance of the SAXXMLReader, sets the ContentHandler, and starts the parse operation.