Scheme of the interaction between an application and an XML parser

    SAX Application          plug  SAX-compliant XML parser
    -----------------------        ------------------------
1.  register handlers        -  >  set-handler methods
2.  start parse              -  >  parse method
3.  event-handling methods   <  -  report events
    request location info    -  >  locator methods

This scheme shows how the application is plugged into the parser. Since this is a two-way interaction both ends are partly male, partly female.:-) Male pins: requesting end, female pins: responding end.

  1. The application registers its handlers with the parser. The parser has setDocumentHandler, setDTDHandler, setEntityResolver, and setErrrorHandler methods for this purpose.

  2. The application starts the parser by calling its parse method.

  3. The parser reports events and transfers data by calling the methods of the application's handlers.

    When called, the application's document handler methods may call back to the parser for information about the location of the reported event or transferred data in the XML source document. For this purpose the parser has the methods of the Locator class. This feature is only available if the parser registered a locator with the document handler, through the DocumentHandler's setDocumentLocator method.