XML schema to COBOL mapping
The DFHSC2LS and DFHWS2LS utility programs support mappings between XML schema definitions and COBOL data structures.
- COBOL reserved words are prefixed with '
X
'.
For example, DISPLAY becomes XDISPLAY.
- Characters other than A-Z, a-z, 0-9, or hyphen are replaced with '
X
'.
For example, monthly_total becomes monthlyXtotal . You can use the MAPPING-OVERRIDES parameter to change the way other characters are handled. For example, if you set the value UNDERSCORES-AS-HYPHENS , any underscore in the XML is converted to a hyphen instead of an X. So monthly_total becomes monthly-total.
- If the last character is a hyphen, it is replaced with '
X
'.
For example, ca-request- becomes ca-requestX.
- If the schema specifies that the variable has varying cardinality
(that is,
minOccurs
and
maxOccurs
are specified on an
xsd:element
with different values), and the schema element name is longer than
23
characters, it is truncated to that length.
If the schema specifies that the variable has fixed cardinality and the schema element name is longer than 28 characters, it is truncated to that length.
- Duplicate names in the same scope are made unique by the addition
of one or two numeric digits
to the second and subsequent instances of the name.
For example, three instances of year become year , year1 , and year2.
- Five characters are reserved for the strings
-cont
or
-num
,
which are used when the schema specifies that the variable has varying
cardinality; that is, when
minOccurs
and
maxOccurs
are specified with different values.
For more information, see Variable arrays of elements.
- For attributes, the previous rules are applied to the element
name. The prefix
attr-
is added to the element name, and is followed by
-value
or
-exist
. If the total length is longer than 28 characters, the element
name is
truncated. For more information, see
Support for XML attributes.
The nillable attribute has special rules. The prefix attr- is added, but nil- is also added to the beginning of the element name. The element name is followed by -value . If the total length is longer than 28 characters, the element name is truncated.
- If the MAPPING-LEVEL parameter is set to 1.2 or higher and the CHAR-VARYING parameter is set to NULL, variable-length character data is mapped to null-terminated strings and an extra character is allocated for the null-terminator.
- If the
MAPPING-LEVEL
parameter is set to 1.2 or higher and the
CHAR-VARYING
parameter is set to YES, variable-length character data is mapped
to two related elements: a length field and a data field. For
example:
maps to:<xsd:simpleType name="VariableStringType"> <xsd:restriction base="xsd:string"> <xsd:minLength value="1"/> <xsd:maxLength value="10000"/> </xsd:restriction> </xsd:simpleType> <xsd:element name="textString" type="tns:VariableStringType"/>15 textString-length PIC S9999 COMP-5 SYNC 15 textString PIC X(10000)
| Schema simple type | COBOL data description |
|---|---|
|
Mapping level 2.0 and below:
Not supported Mapping level 2.1:
Supported |
|
Mapping level 1.0:
Not supported Mapping level 1.1 and higher:
PIC X(255) |
where
type
is one of:
|
All mapping levels:
PIC X( |
where
type
is one of:
|
When
CCSID=1200
at mapping level 4.0 and higher:
PIC N( |
where
type
is one of:
|
All mapping levels:
PIC X(32) |
|
Mapping level 1.2 and below:
PIC X(32) Mapping level 2.0 and higher:
PIC X(40) Mapping level 3.0 and higher: PIC S9(15) COMP-3 The format is CICS ABSTIME. |
where
type
is one of:
|
All mapping levels:
PIC X DISPLAY |
|
All mapping
levels:
PIC S9999 COMP-5 SYNC or PIC S9999 DISPLAY |
|
All mapping levels:
PIC 9999 COMP-5 SYNC or PIC 9999 DISPLAY |
|
All mapping levels:
PIC S9(18) COMP-3 |
|
All mapping levels:
PIC S9(9) COMP-5 SYNC or PIC S9(9) DISPLAY |
|
All mapping levels:
PIC 9(9) COMP-5 SYNC or PIC 9(9) DISPLAY |
|
All mapping levels:
PIC S9(18) COMP-5 SYNC or PIC S9(18) DISPLAY |
|
All mapping levels:
PIC 9(18) COMP-5 SYNC or PIC 9(18) DISPLAY |
|
All mapping levels:
If
WIDE-COMP3=FULL:
PIC 9( ![]() Otherwise:
PIC 9( where p = m - n. |
|
All mapping levels:
PIC X DISPLAY |
|
Mapping level 1.0:
Not supported Mapping level 1.1 and higher:
PIC X(255) |
|
Mapping level 1.0:
Not supported Mapping level 1.1 and higher:
PIC X(255) |
where
the length is not defined.
|
Mapping level 1.0:
Not supported Mapping level 1.1:
PIC X( where y =4×(ceil( z /3)). ceil( x ) is the smallest integer greater than or equal to x. Mapping level 1.2 and
higher:
PIC X( PIC X(16) |
|
Mapping level 1.1 and below:
PIC X(32) Mapping level 1.2 and higher:
COMP-1 Note: The
IBM®
Hexadecimal Floating Point (HFP) data representation
is not exactly the same as the IEEE-754-1985 representation that
is
used for XML. Some values might not convert exactly from one
representation
to the other. Some extremely large or small values might not be
valid
for
xsd:float
data types. Some values might lose
precision when converted to or from HFP representation. If precise
conversions are important, consider replacing use of COMP-1
data types
with fixed precision alternatives.
|
|
Mapping level 1.1 and below:
PIC X(32) Mapping level 1.2 and higher:
COMP-2 Note: The
IBM
Hexadecimal Floating Point (HFP) data representation
is not exactly the same as the IEEE-754-1985 representation that
is
used for XML. Some values might not convert exactly from one
representation
to the other. Some extremely large or small values might not be
valid
for
xsd:double
data types. Some values might lose
precision when converted to or from HFP representation. If precise
conversions are important, consider replacing use of COMP-2
data types
with fixed precision alternatives.
|
Some of the schema types shown in the table map to a COBOL format of COMP-5 SYNC or of DISPLAY, depending on the values (if any) that are specified in the minInclusive and maxInclusive facets:
- For signed types (
short
,
int
, and
long
),
DISPLAY is used when the following are
specified:
where a is a string of '9's.<xsd:minInclusive value="- a"/> <xsd:maxInclusive value=" a "/> - For unsigned types (
unsignedShort
,
unsignedInt
, and
unsignedLong
), DISPLAY is used when the following are
specified:
where a is a string of '9's.<xsd:minInclusive value="0"/> <xsd:maxInclusive value=" a "/>
When any other value is specified, or no value is specified, COMP-5 SYNC is used.
If
WIDE-COMP3=FULL:
