XML parser in COBOL

COBOL for AIX provides an event-based interface that lets you parse XML documents and transform them to COBOL data structures.

The XML parser finds fragments within the source XML document, and your processing procedure acts on those fragments. The fragments are associated with XML events; you code the processing procedure to handle each XML event.

Execution of the XML PARSE statement begins the parsing and establishes the processing procedure with the parser. The parser transfers control to the processing procedure for each XML event that it detects while processing the document. After processing the event, the processing procedure automatically returns control to the parser. Each normal return from the processing procedure causes the parser to continue analyzing the XML document to report the next event. Throughout this operation, control passes back and forth between the parser and the processing procedure.

In the XML PARSE statement, you can also specify two imperative statements to which you want control to be passed at the end of the parsing: one if a normal end occurs, and the other if an exception condition exists.

The following figure shows a high-level overview of the basic exchange of control between the parser and your COBOL program:

This image shows an overview of XML parsing flow.Link to detail.

Normally, parsing continues until the entire XML document has been parsed.

The XML parser checks XML documents for most aspects of well formedness. A document is well formed if it adheres to the XML syntax in the XML specification and follows some additional rules such as proper use of end tags and uniqueness of attribute names.

related concepts  
XML input document encoding
  

related tasks  
Parsing XML documents    
Handling XML PARSE exceptions  
Terminating XML parsing  

related references  
The encoding of XML documents  
XML conformance
    
XML specification