Next: 8.3 COBOL level
Up: 8. Principles of generation
Previous: 8.1 The meta-data
Contents
Index
8.2 The COBOL copybook generation
In an XML file, the elements can be classified in
3 categories :
- Root : the first XML element.
It's ignored in the generation process and is not part of the generated
COBOL copybook.
- First child : the second XML element.
Each time it appears, the meta-data analysis of
the XML elements is (re-)started. It corresponds to the first COBOL
item in the copybook. As this first child
element includes all the other XML elements, its corresponding COBOL
item is a grouping item, with the lowest level
and a unique occurrence.
- Other child elements: the other XML elements.
They are analyzed to extract the meta-data needed
to build the rest of the COBOL copybook.
The COBOL copybook generation process take place in the following
steps :
- The XML file is read record per record until the end of the file.
- The first child is then searched.
- Each XML element or attributes generates a COBOL item
applying the following rules :
- The name of the XML element or attribute
is capitalized and dashes (''-'')
are translated to underscore (''_'').
For example : <cobol_item_01> becomes COBOL-ITEM-01.
COBOL item names are checked against a COBOL reserved word list8.1. A warning message is issued if the generated item name appears in
this list,
- Meta-data of the content8.2 of the XML element and attributes
is extracted : length, type and sign.
- Length of item is rounded if requested (see sub-section
).
A COBOL item is then created.
- Each time the XML first child is found,
the analysis is restarted and the meta-data is updated
if necessary. For example, if the content length of
an XML element is greater than the current length
of its corresponding COBOL item, the length is updated. The contrary
is, of course, not true.
- When the end of the XML file is reached :
- The item list is then checked against elementary
or grouping items occurring
more than one time. If this is the case, only the first occurrence
of the item is kept, the others are deleted and an occurrence
counter is created
- The starting position of each COBOL item is computed. Although, it's
not necessary for the COBOL copybook, it is used for final reporting.
- The COBOL copybook is written, indenting the items according to their
COBOL level.
Next: 8.3 COBOL level
Up: 8. Principles of generation
Previous: 8.1 The meta-data
Contents
Index
sunuraxi@users.sourceforge.net