Program structure for example 8

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, example08.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 TEXT
 Address-Struct
 Document-Pointer
 Document-Length
 "Address-Struct".

Execute the XML EXPORT TEXT statement specifying: the data item address, the XML document text pointer, the XML document text length, and the ModelFileName#DataName parameter value.

If Not XML-OK Go To Z.

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

Verifying syntax

COBOL Statement Description
XML TEST WELLFORMED-TEXT
 Document-Pointer
 Document-Length.

Execute the XML TEST WELLFORMED-TEXT statement specifying the XML document text pointer.

If Not XML-OK Go To Z.

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

Verifying content

COBOL Statement Description
XML VALIDATE TEXT
 Document-Pointer
 Document-Length
 "example08".

Execute the XML VALIDATE TEXT statement specifying: the XML document text pointer the XML document text length and the ModelFileName#DataName parameter value.

If Not XML-OK Go To Z.

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

Copying an XML document to a file

COBOL Statement Description
XML PUT TEXT
 Document-Pointer
 Document-Length
 "address08".

Execute the XML PUT TEXT statement specifying: the XML document text pointer the XML document text length and the document filename.

If Not XML-OK Go To Z.

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

Releasing the XML document memory

COBOL Statement Description
XML FREE TEXT
 Document-Pointer.

Execute the XML FREE TEXT statement specifying the XML document text pointer.

If Not XML-OK Go To Z.

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

Program exit logic

Same as example 1.

Termination test logic

Same as example 1.

Status display logic

Same as example 1.