Processing XML input
You can process XML input in a COBOL program by using the
XML PARSE statement is the COBOL
language interface to either of two high-speed XML parsers. You use
XMLPARSE compiler option to select the appropriate
parser for your application:
XMLPARSE(XMLSS)selects the z/OS® XML System Services parser.
This option provides enhanced features such as namespace processing, validation of XML documents with respect to an XML schema, and conversion of text fragments to national character representation (Unicode UTF-16).
XMLPARSE(COMPAT)selects the XML parser that is built into the COBOL library.
This option provides compatibility with XML parsing in Enterprise COBOL 3 and 4.
Processing XML input involves passing control between the XML parser and a processing procedure in which you handle parser events.
Use the following COBOL facilities to process XML input:
XML PARSEstatement to begin XML parsing and to identify the source XML document and the processing procedure.You can also use the following optional phrases of the
ENCODINGto specify the encoding of the XML document
VALIDATINGto identify an XML schema against which the XML document is to be validated
- The processing procedure to control the parsing, that is, receive and process XML events and associated document fragments, and return to the parser for continued processing
- Special registers to exchange information between the parser and
the processing procedure:
XML-CODEto receive the status of XML parsing and, in some cases, to return information to the parser
XML-EVENTto receive the name of each XML event from the parser
XML-INFORMATIONprovides a mechanism to easily determine whether an XML event is complete
XML-NTEXTto receive XML document fragments that are returned as national character data
XML-TEXTto receive document fragments that are returned as alphanumeric data
XML-NNAMESPACEto receive a namespace identifier for a
NAMESPACE-DECLARATIONXML event, or for an element name or attribute name that is in a namespace
XML-NNAMESPACE-PREFIXto receive a namespace prefix for a
NAMESPACE-DECLARATIONXML event, or for an element name or attribute name that is prefixed
- The optional
RETURNING NATIONALphrase of the
XML PARSEstatement to indicate that the fragments of an XML document in an alphanumeric data item are to be converted to UTF-16 and returned to the processing procedure in the national special registers
You can use the
NATIONAL phrases of the
XML PARSE statement only if
XMLPARSE(XMLSS) is in effect.
Link-edit consideration: COBOL
programs that contain the
XML PARSE statement must
be link-edited with
XML parser in COBOL
Accessing XML documents
Parsing XML documents
Handling XML PARSE exceptions
Terminating XML parsing