The XML-to-FD Utility

In order to prepare your COBOL program for use with XML documents, you must first determine the nature of the data in the documents and the meaning of the tags.

The ACUCOBOL-GT Development System includes an xml2fd utility to read XML documents and produce FDs and SELECT statements suitable for inclusion in a COBOL program. Because the structure of valid XML documents is very specific and well defined, the utility produces the best results using valid documents.

The FD created by the utility has the same structure as the XML file. The parent/child relationships of all the data elements are present. Array definitions are included. The data types are defined. If a schema is included with the file, the DTD has a high degree of accuracy. If a DTD is included, the utility analyzes the content and makes an intelligent guess at the data types (e.g., numerical data is assigned the NUMBER type, and so on). Raw XML produces FDs that are a best guess based on the structure of the elements.

The utility also creates a SELECT statement for each data file. Once the FDs and SELECTs are created, you should modify them as required, then include them in the COBOL program. When you include the FDs and SELECT statements in your COBOL program, it can understand, process, and even output XML data that is structured like the existing file.