In your processing procedure, code statements to handle XML events.
For each event that the parser encounters, the parser passes information to the processing procedure in several special registers. Use the content of those special registers to populate COBOL data structures and to control the processing.
Examine the XML-EVENT special register to determine which event the parser passed to the processing procedure. XML-EVENT contains an event name, such as 'START-OF-ELEMENT'. Obtain the text associated with the event from the XML-TEXT or XML-NTEXT special register.
When used in nested programs, the XML special registers are implicitly defined as GLOBAL in the outermost program.
For additional details about the XML special registers, see the following table.
| Special register | Implicit definition and usage | Content |
|---|---|---|
| XML-EVENT1, 3 | PICTURE X(30) USAGE DISPLAY VALUE SPACE |
The name of the XML event |
| XML-CODE2 | PICTURE S9(9) USAGE BINARY VALUE ZERO |
An exception code or zero for each XML event |
| XML-TEXT1, 4 | Variable-length elementary category alphanumeric item | Text (corresponding to the event that the parser encountered) from the XML document if you specify an alphanumeric item for the XML PARSE identifier |
| XML-NTEXT1 | Variable-length elementary category national item | Text (corresponding to the event that the parser encountered) from the XML document if you specify a national item for the XML PARSE identifier |
|
||
Restrictions:
You can code a STOP RUN statement in a processing procedure to end the run unit.
The compiler inserts a return mechanism after the last statement in each processing procedure.
Example: program for processing XML
related concepts
XML events
XML-CODE
XML-TEXT and XML-NTEXT
related tasks
Terminating XML parsing