This COBOL program illustrates how an XML document is generated from a COBOL data item and then how the syntax and content of an XML document may be verified.
The program first writes (or exports) an XML document file from the content of a COBOL data item. Then the program verifies that the generated document is well-formed. Finally, the program verifies that the content of the document conforms to the schema file.
Note: On UNIX systems, the underlying XML parser, libxml, does not support schema validation.
This example uses the following XML statements:
- XML INITIALIZE, which initializes or opens a session with XML Extensions.
- XML EXPORT FILE, which constructs an XML document (as a file) from the content of a COBOL data item.
- XML TEST WELLFORMED-FILE, which verifies that an XML document conforms to XML syntax rules.
- XML VALIDATE FILE, which verifies that the content of an XML document conforms to rules specified by an XML schema file.
- XML TERMINATE, which terminates or closes the session with XML Extensions.