COBOL2000 the reading and analysis of XML documents. This can be done in two different ways:
On a structure-oriented basis, i.e. the XML document is transformed into a tree. This tree permits data to be positioned on nodes and to be transferred from (multiple) nodes to the COBOL program.
On an event-oriented basis, i.e. the XML document is processed purely sequentially, and each syntax unit which is detected is made available in special registers for further processing.
The language elements which are available are specifically for the processing type selected. XML documents are actually analyzed and parsed by a separate open source program package called Parser. Further prerequisites must therefore be fulfilled for such programs to run, see the "COBOL2000 User Guide" [1].
Structure-oriented processing
This processing type regards an XML document as a file of the new file organization form 'XML' which can be made available both in a traditional file and in memory. In both cases it requires a file control entry and a file description entry. The record description entries of the FD do not provide the content of the file, but describe the tree structure of the XML document, either as a whole or only of the parts of it which are to be processed. New clauses in a data description entry are used to define the assignment of the data items to the nodes in the XML document’s tree presentation. The actual processing, i.e. the positioning and sequential or random reading of the data is then performed using the statements for file processing which have been extended for this purpose.
Event-oriented processing
This processing type uses no special language elements of its own to describe an XML document. The new statement XML PARSE analyzes and parses an XML document which is made available in memory sequentially. Each syntax unit of the document which is detected is made available to the user program in special registers for further processing. The user program can, if required, obtain a picture of the general structure of the document from this.
Assignment of the new language elements to the processing types
Language elements | Structure-oriented | Event-oriented |
File control entry | ||
Extended ASSIGN format | x | |
File organization XML | x | |
Access method XML | x | |
File description entry, record description entry | ||
IDENTIFIED clause | x | |
COUNT clause | x | |
Statements | ||
OPEN, CLOSE | x | |
OPEN DOCUMENT, CLOSE DOCUMENT | x | |
START, READ | x | |
XML PARSE | x | |
Exceptional condition | x | |
Special registers | x |
The description of the language elements is based on the presentation of the XML document as a tree and uses terms which are common in the graphical display of tree structures (see also section "Language elements for processing XML").