Elementary data items are converted
to character format depending on the type of the data item:
- Data items of category alphabetic, alphanumeric,
alphanumeric-edited, DBCS, external floating-point, national, and numeric-edited
are not converted.
- Fixed-point numeric data items other than COMP-5 data items or
binary data items compiled with
the NOSTDTRUNC compiler option are converted as if they were moved to a numeric-edited
item that has:
- As many integer positions as the numeric item has, but with at least one
integer position
- An explicit decimal point, if the numeric item has at least one decimal
position
- The same number of decimal positions as the numeric item has
- A leading '-' picture symbol if the data item is signed (has an S in its
PICTURE clause)
- COMP-5 data items and binary data items compiled with the
NOSTDTRUNC compiler option are converted
in the same way as the other fixed-point numeric items, except for the number
of integer positions. The number of integer positions is computed depending
on the number of '9' symbols in the picture character string as follows:
- 5 minus the number of decimal places, if the data item has 1 to 4 '9'
picture symbols
- 10 minus the number of decimal places, if the data item has 5 to 9 '9'
picture symbols
- 20 minus the number of decimal places, if the data item has 10 to 18 '9'
picture symbols
- Internal floating-point data items are converted as if they were moved
to a data item as follows:
- For COMP-1: an external floating-point data item with PICTURE -9.9(8)E+99
- For COMP-2: an external floating-point data item with PICTURE -9.9(17)E+99
(illegal because of the number of digit positions)
- Index data items are converted as if they were declared USAGE BINARY PICTURE
S9(9).
After any conversion to character format, leading and trailing spaces and
leading zeroes are eliminated, as described under Trimming of generated XML data.
If a data item after any conversion contains any characters that are illegal
in XML content, as specified in the relevant
XML specification, the original data value (that is, the value in the
data item before any conversion or trimming) is represented in hexadecimal,
and an element tag name with the prefix 'hex.' is substituted for the regular
tag name. For example, if data item Customer-Name is found at run time to
contain LOW-VALUES, the XML element tag name 'hex.Customer-Name' is used instead
of the normal 'Customer-Name', and the content is represented as a string
of pairs of zero digits.
Any remaining instances of the five characters & (ampersand), ' (apostrophe), >
(greater-than sign), < (less-than sign), and “ (quotation mark) are
converted into the equivalent XML references '&', ''', '>',
'<', and '"', respectively.
Then, if identifier-1 is a data item of category national, any nonnational values are converted
to national format.