Previous Topic Next topic Print topic


Example 8 Export text, test well-formed text, and validate text

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. Next, 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 TEXT, which constructs an XML document (as a text string) from the content of a COBOL data item.
  • XML TEST WELLFORMED-TEXT, which verifies that an XML document conforms to XML syntax rules.
  • XML VALIDATE TEXT, which verifies that the content of an XML document conforms to rules specified by an XML schema file.
  • XML PUT TEXT, which copies an XML document from a text string to a data file.
  • XML FREE TEXT, which releases the memory that was allocated by XML EXPORT TEXT to hold the XML document as a text string.
  • XML TERMINATE, which terminates or closes the session with XML Extensions.
Previous Topic Next topic Print topic