Next: 2.3 XML to text
Up: 2. Principles of conversion
Previous: 2.1 COBOL copybook analysis
Contents
Index
2.2 Text to XML conversion
This is the easiest conversion. An XML header (<?xml .... ?>)
is first created. Then, one text record is read, item data is extracted
from the current text record and the XML elements
and their content are written one by one. The conversion
process continues until the end of the text file. The XML elements
can be classified in 3 categories :
- Root : this element must be
unique in the whole XML file. That's why, DATA, a COBOL reserved word,
was chosen as root element name. It has no equivalent
in the COBOL copybook.
- First child : it appears each time a
text record is read. It corresponds to the level of
the first COBOL item in the copybook. As this first
child element will include all the other XML elements,
this COBOL item needs to be a grouping item,with
the lowest level and ideally with a unique occurrence.
- Other child elements: The other XML elements.
All of them are built using the following rules :
- The name of the XML element is the capitalized
COBOL item name with dashes (''-'') translated
to underscore (''_''). For example
: COBOL-ITEM-01 will become <cobol_item_01>,
- Content of the XML element is extracted
from the current text record (using the starting position and the
length computed in section
). Characters
are escaped if necessary2.4,
- FILLER clauses are skipped.
- Opened XML tags are closed :
- immediately after the content of an XML element,
- at the end of each COBOL grouping item,
- at then end of the text record,
- at the end of the text file.
If requested, TXT2XML can create a DTD (Document Type
Definition), based on the COBOL copybook, which describes the XML
structure. This DTD can be internal :
Figure:
Internal DTD
![\begin{figure}\par\par
\begin{list}{}{
\setlength{\rightmargin}{\leftmargin...
...ont\ttfamily }\item[]<NUMERIC\_TYPES>
\end{list}
...\end{list}\par
\end{figure}](img7.png) |
or external :
Figure:
XML file with an external DTD reference
![\begin{figure}\par\par
\begin{list}{}{
\setlength{\rightmargin}{\leftmargin...
...ttfamily }\item[]<NUMERIC\_TYPES>
\par
...\end{list}
\end{list}\par
\end{figure}](img8.png) |
Next: 2.3 XML to text
Up: 2. Principles of conversion
Previous: 2.1 COBOL copybook analysis
Contents
Index
sunuraxi@users.sourceforge.net