Rational Developer for System z
Enterprise COBOL for z/OS, Version 4.1, Programming Guide


Writing procedures to process XML

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.

Table 1. Special registers used by the XML parser
Special register Implicit definition and usage Content
XML-EVENT1

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 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.
  1. You cannot use this special register as a receiving data item.
  2. The XML GENERATE statement also uses XML-CODE. Therefore, if you code an XML GENERATE statement in the processing procedure, save the value of XML-CODE before the XML GENERATE statement and restore the saved value after the XML GENERATE statement.
  3. If you specify the RETURNING NATIONAL phrase on the XML PARSE statement for an alphanumeric data item, text is returned in the corresponding national special register. The RETURNING NATIONAL phrase can be specified only when the XMLPARSE(XMLSS) option is in effect.
  4. The parser sets the namespace special registers when the XMLPARSE(XMLSS) option is in effect.

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


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)