CBL2XML Utility

You can use the cbl2xml utility to:

cbl2xml runs at a command prompt, reads a COBOL record, and generates several files. Use the following command-line syntax:

cbl2xml filename
        [-c cpyBook]
        [-x schemaFile]
        [-m mapFile]
        [-p prefix]
        [-d directiveFile]
        [-v validationFile]
        [-noprompt]
        [-nocountin]
        [-fixedfraction][11]

Where the parameters are:

filename The input file for cbl2xml.
  • When converting traditional COBOL data structures to COBOL with XML syntax, this is the filename of a COBOL file being read by cbl2xml. It can be a program with the file extension .cbl, or a copybook with the file extension .cpy.
  • When converting an XML schema to COBOL with XML syntax, this is the filename of an XML schema file being read by cbl2xml. Schema files usually have an .xsd file extension.
cpyBook The filename of a COBOL copybook (.cpy file). cbl2xml generates this file to contain COBOL with XML syntax extensions. If you do not specify this parameter, cbl2xml names the generated file using the name of the COBOL or copybook with -cbl2xml appended to it. For example, if you specify a COBOL program file named account.cbl, the default filename for the copybook containing XML syntax extensions created by cbl2xml is account-cbl2xml.cpy.
schemaFile The filename of a schema file to be created. If you do not specify this parameter, cbl2xml names the schema file the same as the COBOL file, but with an .xsd extension. For example, if you specify a COBOL program file named account.cbl, the default filename for the schema created by cbl2xml is account.xsd.
mapFile The filename of a map file to be created, or the name of an existing map file. The following rules apply:
  • If the map file you specify does not exist, cbl2xml creates a map file based on the information in the specified COBOL file.
  • If the map file you specify does exist, cbl2xml first asks if you want to overwrite it. If you anwer no, it applies the information in the map file to the generated COBOL file. If you answer yes, cbl2xml generates a new map file overwriting the previous contents of that file.

For more information on map files, see the section Mapping COBOL Data to XML Elements.

prefix Specify a prefix to prepend to generated data names. Use this parameter to create data records that are structured the same as the data records in your COBOL file, but that have different data names. This is useful when you want to keep the original data records intact and supply alternative data names for XML use.

The prefix takes the form of a character string. For example, if you specify -p xml-, cbl2xml prepends xml- to the beginning of each data name it generates.

directiveFile If you normally use a Compiler directive file to compile the COBOL program or copybook you are XML-enabling, specify that directive file each time you use cbl2xml.

For more information on directive files, see the topic Compiler Directives.

validationFile The filename of an XML schema or instance document you want to validate. The following rules apply:
  • If you specify a schema, cbl2xml validates that schema based on W3C XML conventions specified at http://www.w3.org/2001/XMLSchema, that is, it validates that the schema itself is a valid schema.
  • If you specify an XML instance document, cbl2xml validates that document against the XML schema specified in the document.
-noprompt Specify this argument when you want cbl2xml to overwrite existing files automatically.
CAUTION:
-noprompt overwrites all files generated by cbl2xml, including map files you have edited, and schema files supplied by third parties. Do not use this parameter unless you are sure you want to overwrite these.
-nocountin Specify this argument to prevent the generation of COUNT IN clauses for generated COBOL data items. This option overrides any values specified in a CBL2XML mapping file.
-fixedfraction[11] This argument sets the fractionDigits to the exact number of fractional digits instead of the maximum number of fractional digits.