Program structure for example 2

The following tables show COBOL statements that relate to performing XML Extensions statements. Some COBOL statements (mostly the DISPLAY statements) have been omitted. The source of this example is in the file, example02.cbl.

Initialization

COBOL Statement

Description

XML INITIALIZE.

Execute the XML INITIALIZE statement (no parameters).

If Not XML -OK Go To Z.

If the statement terminates unsuccessfully, go to the termination logic.

Exporting an XML document

COBOL Statement

Description

Move … To Time-Stamp.

Populate the Time-Stamp field.

XML EXPORT FILE Address-Struct "address02.xml" 
                      "Address-Struct" "toext". 
				  

Execute the XML EXPORT FILE statement specifying: the data item address, the XML document filename, the ModelFileName#DataName parameter value, and the external XSLT stylesheet name.

If Not XML-OK Go To Z.

If the statement terminates unsuccessfully, go to the termination logic.

Importing an XML document

COBOL Statement

Description

Initialize Address-Struct.

Ensure that the Address-Struct structure contains no data.

XML IMPORT FILE Address-Struct "address02.xml"
                      "Address-Struct" "toint".

Execute the XML IMPORT FILE statement specifying: the data item address, the XML document filename, the ModelFileName#DataName parameter value, and the external XSLT stylesheet name.

If Not XML-OK Go To Z.

If the statement terminates unsuccessfully, go to the termination logic.

Program exit logic

COBOL Statement

Description

Z.

Paragraph-name that is a target of error condition GO TO statements.

Copy "lixmltrm.cpy".
Copy in the termination test logic (see the Termination Test Logic table).
Stop Run.  

Terminate the COBOL program.

Copy "lixmldsp.cpy".
Copy in the status display logic (see the Status Display Logic table).

Termination test logic

Same as in example 1.

Status display logic

Same as in example 1.