Try OpenEdge Now
skip to main content
Working with XML
Reading XML Documents with the Simple API for XML (SAX) : Understanding ABL SAX : ABL SAX callbacks
 

ABL SAX callbacks

When the XML parser encounters an XML token, ABL invokes the callback corresponding to that token—if that callback is provided by the developer. If not, the parser continues.
ABL SAX implements callbacks as internal procedures coded by the ABL developer using signatures specified by ABL. Normally, callbacks are placed in a procedure (.p) file that the application runs persistently. But callbacks can also be placed in the driver routine. A driver routine is one that calls the SAX-PARSE( ) or SAX-PARSE-FIRST( ) method. In either case, your application assigns the containing procedure's handle to the SAX-reader HANDLER attribute. (The HANDLER attribute defaults to a handle to the driver routine). Then, the application starts the parse.
Note: Although there are many callbacks in the interface specified by the SAX 2.0 standard, most applications use just a few. These are StartElement, Characters, and EndElement.
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 STOP-PARSING( ) method:
SELF:STOP-PARSING( ).
The following fragment uses SELF within a callback to store data in the SAX-reader PRIVATE-DATA attribute:
SELF:PRIVATE-DATA = "xyz123".
For information on the SAX parser's current location in the XML source, use the following attributes of SAX-reader:
*LOCATOR-COLUMN-NUMBER
*LOCATOR-LINE-NUMBER
*LOCATOR-PUBLIC-ID
*LOCATOR-SYSTEM-ID
Note: These attributes are valid only within a callback.
The following table summarizes the ABL SAX callbacks. For a complete description, see SAXcallback reference.
Table 7. 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