Format conversion of elementary data
Elementary data items within identifier-2 are converted in a sequence of several steps, some of them are optional as described below.
Conversion to character format:
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, national-edited, and numeric-edited are not converted.
- Fixed-point numeric data items other than COMPUTATIONAL-5 (COMP-5)
binary data items or binary data items compiled with the TRUNC(BIN)
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)
- COMPUTATIONAL-5 (COMP-5) binary data items or binary data items
compiled with the TRUNC(BIN) 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 COMP-5 PICTURE S9(9).
Trimming:
After any conversion to character format, leading and trailing spaces and leading zeroes are eliminated, as described under Trimming of generated XML data.
Conversion to the document encoding:
If identifier-1 is a data item of category national, any nonnational values are converted to national format.
Conversion of special characters to XML references:
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.
Replacement of out-of-range Unicode characters:
Any remaining Unicode character that has a Unicode scalar value greater than x'FFFF' is replaced by an XML character reference. For example, if the document contains a character with Unicode scalar value x'10813', in UTF-16, that value is represented by the surrogate pair (NX'D802', NX'DC13'), which is replaced by the reference '𐠓'. For a document encoding of UTF-8, the byte sequence that is equivalent to character reference '𐠓' is X'F090A093'.