Previous Topic Next topic Print topic


Data naming

While the COBOL language allows a data-name to begin with a digit, XML does not allow an element name to begin with a digit. For example, the following line defines a valid COBOL data-name, but when using XML Extensions, the data-name will result in an invalid XML element name:

03 1099-something-field
The COBOL compiler will not detect the issue with the data-name with respect to XML Extensions. However, XML Extensions will detect the problem at runtime and report the error. A workaround that avoids the need to modify any COBOL Procedure Division code when data-names begin with a digit is to add a non-digit initial character to the data-name and then redefine that data item with the original data-name, as in the following:
03 x1099-something-field PIC X(10).
03 1099-something-field REDEFINES x1099-something-field
 SAME AS x1099-something-field.

The data-name 1099-something-field will result in the Procedure Division compiling successfully and the x1099-something-field will result in a valid element name for XML Extensions.

Previous Topic Next topic Print topic