Progress
External Program
Interfaces
Progress SAX Callbacks
When the XML parser encounters an XML token, Progress invokes the callback corresponding to that token — if that callback is provided by the developer. If not, the parser continues.
Progress SAX implements callbacks as internal procedures coded by the 4GL SAX developer using signatures specified by Progress. Normally, callbacks are placed in a procedure (
.p
) file that the application runs persistently. But callbacks can also be placed in the driver routine, which is the routine that calls the SAX-PARSE() or SAX-PARSE-FIRST() method. In whichever procedure callbacks are placed, the application assigns that procedure’s handle to the SAX-READER’s HANDLER attribute. (HANDLER defaults to a handle to the driver routine). Then, the application starts the parse.NOTE: Although there are many callbacks in the SAX2 interface, your application might need to use only a few — most likely StartElement, Characters, and EndElement. You might not care about the other callbacks.Within a callback, to get a handle to the SAX-READER object that invoked the callback, use the SELF system handle.
The following fragment uses SELF within a callback to call the SAX-READER’s STOP-PARSING() method:
The following fragment uses SELF within a callback to store data in the SAX-READER’s PRIVATE-DATA attribute:
For information on the SAX parser’s current location in the XML source, use the following attributes of SAX-READER:
NOTE: These attributes are valid only within a callback.Table 12–2 summarizes the callbacks. For complete descriptions, see the "SAX Callback Reference" section in this chapter.
Table 12–2: SAX Callback Summary This Callback... Lets You... Tell the parser where to find an external entity Process various XML tokens Process notations and unparsed entities Handle errors
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |