XML Support in AcuBench

The ACUCOBOL-GT runtime has a file system interface for XML files, called AcuXML, that seamlessly converts XML data to COBOL data and vice versa. Information about working with XML data can be found in Working with XML Data.

When you make use of the AcuXML interface, you can use the xml2fd utility to derive an FD and SELECT statement from an XML file. When a file of type XML is selected, the import process must pass through the xml2fd utility. This utility's interface helps to guide you through the import of the XML file to an FD file, which is written into a project's .fd folder and imported into the AcuBench graphical File Designer.

xml2fd also returns a list of the lines where it's guessing about the data type. This prints to an stderr file and can be viewed in the Output window. The graphical File Designer is displayed, along with Output window information. When you click on a line in the Output window, the cursor is positioned at the line in the File Designer where the guessing occurred. You can then change the Picture clause, if desired, prior to regenerating the code.

To use xml2fd from within AcuBench, do the following:

  1. Select Xml2FD from the Tools menu, or right-click a project node in the Data view and select XML2FD.

    When you invoke xml2fd from the Data view, the utility understands the context of the project and prefills the -d option entry field with the name of the directory in which the FD and SL are stored.

    When xml2fd is invoked from the Tools menu, it does not have this context information, and therefore does not prefill the -d entry field.

  2. If necessary, click the browse (“...”) button next to the Output directory (-d) field to navigate to the directory into which you want the FD and SL to be generated.

    Use the -f and -s options if you prefer to generate the FD and SL into separate directories.

    Note that selecting -d causes -f and -s to be disabled, because they are mutually exclusive options. Likewise, if -f or -s is selected, -d is disabled.

    In the absence of any instructions (-d, -f, or -s) about where to write the output, output is written to the current working directory, typically the root of the active project.

  3. Set the -n option to specify the number of records to be read by the utility before it arrives at field descriptions in the FD. In very large XML files, it may not be desirable to read the entire file to derive the FD. On the other hand, it may be necessary to read more than one record to confirm a best guess for intended field descriptions in a record. The value of -n must be numeric and greater than 0.
  4. If you want to add a standard prefix to data items in the FD, use the -p option.
  5. Use the -o option with a numeric value greater than 0 to instruct xml2fd to look for cases within the record where it is appropriate to assign an OCCURS clause. The value that you specify provides a default number to assign in the OCCURS clause. In complex cases where an FD has more than one OCCURS clause and where the number of OCCURS differs, users must manually change the generated representation of the FD in the graphical designer.
  6. As you make changes in the XML2FD Utility window, the Options field displays the xml2fd command line that you are constructing. Verify this command line, then click Start to build the FD and SELECT.

    The Output window prints the output of xml2fd. More information about this utility can be found in XML-to-FD Utility.