Next: 3. Signed and binary
Up: 2. Principles of conversion
Previous: 2.2 Text to XML
Contents
Index
2.3 XML to text conversion
This conversion is a little bit more difficult and even in some cases
impossible. Remember, TXT2XML implements only a subset of XML and
COBOL. For example, this XML file :
Figure:
Nonconvertible XML file
 |
In this file, the XML element city is a complex
one. It includes the simple element sky but
also a content (Hot and sunny). The corresponding
COBOL copybook would be something like :
Figure:
Corresponding COBOL copybook
 |
This is impossible in COBOL : a
grouping
item can't have a
picture clause.
2.5
So, not all the XML files can be converted. But, with avalid
COBOL copybook, the XML file is read one line at the time and data
is extracted using the following rules :
- Mixed XML content is not
supported,
- All the XML tags and contents may expand
on more than one line,
- XML headers starting with <?xml and ending with ?> are
skipped,
- XML entities starting with <!ENTITY and ending
with > are not supported. If such a declaration is
found, the conversion process is aborted,
- XML internal and external document type declaration starting with
<!DOCTYPE and ending with either > or ]> are
skipped,
- XML comments starting with <!- and ending
with -> are skipped,
- The first child element
is then searched. Each time an XML first child closing tag
is found, a text record is written and a new text record is initialized
with default values from the COBOL copybook,
- Attributes of the first
child element are supported. But, attributes of the
root element are ignored.
- Each XML element, even without a content,
must have an equivalent in the COBOL copybook.
To find it, the XML element name is capitalized
and underscores are translated to dashes.
For example : <cobol_item_01> will become COBOL-ITEM-01
and is searched in the COBOL copybook,
- Each XML attribute may have an equivalent
in the COBOL copybook,
- XML attributes like xml:space are ignored,
- Each time a content is found, it's length and data
type are checked against the characteristics of the corresponding
COBOL item. Numeric items are right justified and
left zero filled. If necessary characters are escaped.2.6
- If some XML elements or attributes
are missing, conversion continues with the new element found. Missing
COBOL items are left to their default value
(see section
).
- Empty XML elements, even with attributes,
are supported.
Next: 3. Signed and binary
Up: 2. Principles of conversion
Previous: 2.2 Text to XML
Contents
Index
sunuraxi@users.sourceforge.net