In your processing procedure, code statements to handle XML events.
For each event that the parser encounters, it passes information to your processing procedure in several special registers, as shown in the following table. Use the content of these special registers to populate COBOL data structures and to control the processing.
When used in nested programs, these special registers are implicitly defined as GLOBAL in the outermost program.
| Special register | Implicit definition and usage | Content |
|---|---|---|
| XML-EVENT1 | PICTURE X(30) USAGE DISPLAY |
The name of the XML event |
| XML-CODE2 | PICTURE S9(9) USAGE BINARY |
An exception code or zero for each XML event |
| XML-TEXT1 | Variable-length elementary category alphanumeric item; size limit of 134,180,862 bytes | Text (corresponding to the event that the parser encountered) from the XML document if you specify an alphanumeric item for the XML PARSE identifier3 |
| XML-NTEXT1 | Variable-length elementary category national item; size limit of 67,090,431 national characters (134,180,862 bytes) | Text (corresponding to the event that the parser encountered) from the XML document if you specify a national item for the XML PARSE identifier3 |
| XML-NAMESPACE1, 4 | Variable-length elementary category alphanumeric item; size limit of 32,768 bytes | The namespace identifier for a NAMESPACE-DECLARATION XML event or for an element or attribute name that is in a namespace, when the XML document is in an alphanumeric data item.3 |
| XML-NNAMESPACE1, 4 | Variable-length elementary category national item; size limit of 16,384 national characters (32,768 bytes) | The namespace identifier for a NAMESPACE-DECLARATION XML event or for an element or attribute name that is in a namespace, when the XML document is in a national data item or the RETURNING NATIONAL phrase is specified on the XML PARSE statement. |
| XML-NAMESPACE-PREFIX1, 4 | Variable-length elementary category national item; size limit of 4,096 bytes | The prefix, if any, for a NAMESPACE-DECLARATION XML event or for an element or attribute name that is in a nondefault namespace, when the XML document is in an alphanumeric data item.3 |
| XML-NNAMESPACE-PREFIX1, 4 | Variable-length elementary category national item; size limit of 2,048 national characters (4,096 bytes) | The prefix, if any, for a NAMESPACE-DECLARATION XML event or for an element or attribute name that is in a nondefault namespace, when the XML document is in a national data item or the RETURNING NATIONAL phrase is specified on the XML PARSE statement. |
|
||
Restrictions:
The compiler inserts a return mechanism after the last statement in each processing procedure. You can code a STOP RUN statement in a processing procedure to end the run unit.
Example: program for processing XML
related concepts
XML-CODE
XML-TEXT and XML-NTEXT
XML-NAMESPACE and XML-NNAMESPACE
XML-NAMESPACE-PREFIX and XML-NNAMESPACE-PREFIX
related tasks
Transforming XML text to COBOL data items
Converting to or from national (Unicode) representation
related references
XML-EVENT
XML PARSE exceptions that allow continuation
XML PARSE exceptions that do not allow continuation
XMLPARSE
XML PARSE statement (Enterprise COBOL Language Reference)