XML schema to COBOL mapping
The DFHSC2LS and DFHWS2LS utility programs support mappings between XML schema definitions and COBOL data structures.
How XML schema element names are mapped to COBOL
- COBOL reserved words are prefixed with '
X'.For example,
DISPLAYbecomesXDISPLAY. - Characters other than A-Z, a-z, 0-9, or hyphen are replaced with '
X'.For example,
monthly_totalbecomesmonthlyXtotal. 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. Somonthly_totalbecomesmonthly-total. - If the last character is a hyphen, it is replaced with '
X'.For example,
ca-request-becomesca-requestX. - If the schema specifies that the variable has varying cardinality (that is,
minOccursandmaxOccursare specified on anxsd:elementwith 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
yearbecomeyear,year1, andyear2.Should the above behavior be undesirable the user can specify
MAPPING-OVERRIDES=NO-ARRAY-NAME-INDEXINGas input to the utility which disables the addition of one or two numeric digits to the second and subsequent instances of the name. - Five characters are reserved for the strings
-contor-num, which are used when the schema specifies that the variable has varying cardinality; that is, whenminOccursandmaxOccursare 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-valueor-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, butnil-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.
The total length of the resulting name is 30 characters or less.
How XML schema types are mapped to COBOL
- 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:
|
where type is one of:
|
All mapping levels:
|
where type is one of:
|
When CCSID=1200 at mapping level 4.0 and higher:
|
where type is one of:
|
All mapping levels:
|
|
Mapping level 1.2 and below:
Mapping level 2.0 and higher:
Mapping level 3.0 and higher:
The format is CICS ABSTIME. |
where type is one of:
|
All mapping levels:
|
|
All mapping levels:
or
|
|
All mapping levels:
or
|
|
All mapping levels:
|
|
All mapping levels:
or
|
|
All mapping levels:
or
|
|
All mapping levels:
or
|
|
All mapping levels:
or
|
|
All mapping levels: If WIDE-COMP3=FULL:
Otherwise:
where p = m - n. |
|
All mapping levels:
The value x'00' implies false, x'01' implies true. |
|
Mapping level 1.0: Not supported Mapping level 1.1 and higher:
|
|
Mapping level 1.0: Not supported Mapping level 1.1 and higher:
|
where the length is not defined. |
Mapping level 1.0: Not supported Mapping level 1.1:
where y =4×(ceil( z /3)). ceil( x ) is the smallest integer greater than or equal to x. Mapping level 1.2 and higher:
where the length is fixed.
where the length is not defined. The field holds the 16-byte name of the container that stores the binary data. |
|
Mapping level 1.1 and below:
Mapping level 1.2 and higher:
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:
Mapping level 1.2 and higher:
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, andlong), DISPLAY is used when the following are specified:
where<xsd:minInclusive value="-a"/> <xsd:maxInclusive value="a"/>ais a string of '9's. - For unsigned types (
unsignedShort,unsignedInt, andunsignedLong), DISPLAY is used when the following are specified:
where<xsd:minInclusive value="0"/> <xsd:maxInclusive value="a"/>ais a string of '9's.
When any other value is specified, or no value is specified, COMP-5 SYNC is used.