XML schema to C and C++ mapping

The DFHSC2LS and DFHWS2LS utility programs support mappings between the XML schema definitions that are included in each web service description and C and C++ data types.

How XML schema element names are converted to C and C++

The CICS® assistants generate unique and valid names for C and C++ variables from the schema element names using the following rules:

  1. Characters other than A-Z, a-z, 0-9, or _ are replaced with ' X '.

    For example, monthly-total becomes monthlyXtotal.

  2. If the first character is not an alphabetic character, it is replaced by a leading ' X '.

    For example, _monthlysummary becomes Xmonthlysummary.

  3. If the schema element name is longer than 50 characters, it is truncated to that length.
  4. Duplicate names in the same scope are made unique by the addition of one or more numeric digits.

    For example, two instances of year become year and year1.

  5. 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 on an xsd:element.

    For more information, see Variable arrays of elements.

  6. For attributes, the previous rules are applied to the element name. The prefix attr_ is added to the element name, and it is followed by _value or _exist. If the total length is longer than 28 characters, the element name is truncated.

    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.

The total length of the resulting name is 57 characters or less.

How XML schema types are mapped to C and C++

DFHSC2LS and DFHWS2LS map schema types to C and C++ data types according to Table 1. The following rules also apply:
  • 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.
Table 1. Mapping reference for XML schema types
Schema simpleType C and C++ data type
<xsd:simpleType>
  <xsd:restriction base="xsd:anyType">
  </xsd:restriction>
</xsd:simpleType>

Mapping level 2.0 and below: Not supported

Mapping level 2.1 and higher: Supported

<xsd:simpleType>
  <xsd:restriction base="xsd:anySimpletype">
  </xsd:restriction>
</xsd:simpleType>

Mapping level 1.0: Not supported

Mapping level 1.1 and higher:
char[255]
<xsd:simpleType>
  <xsd:restriction base="xsd:type">
    <xsd:length value="z"/>
  </xsd:restriction>
</xsd:simpleType>
where type is one of:
  • string
  • normalizedString
  • token
  • Name
  • NMTOKEN
  • language
  • NCName
  • ID
  • IDREF
  • ENTITY
  • hexBinary
All mapping levels:
char[z]
<xsd:simpleType>
  <xsd:restriction base="xsd:type">
    <xsd:length value="z"/>
  </xsd:restriction>
</xsd:simpleType>
where type is one of:
  • string
  • normalizedString
  • token
  • Name
  • NMTOKEN
  • language
  • NCName
  • ID
  • IDREF
  • ENTITY
When CCSID=1200 at mapping level 4.0 and higher:
char16_t[z]
<xsd:simpleType>
  <xsd:restriction base="xsd:type">
  </xsd:restriction>
</xsd:simpleType>
where type is one of:
  • duration
  • date
  • decimal
  • time
  • gDay
  • gMonth
  • gYear
  • gMonthDay
  • gYearMonth
All mapping levels:
char[32]
<xsd:simpleType>
  <xsd:restriction base="xsd:dateTime">
  </xsd:restriction>
</xsd:simpleType>
Mapping level 1.2 and below:
char[32]
Mapping level 2.0 and higher:
char[40]
Mapping level 3.0 and higher:
char[8]

The format of the time stamp is CICS ABSTIME.


<xsd:simpleType>
  <xsd:restriction base="xsd:byte">
  </xsd:restriction>
</xsd:simpletype>
All mapping levels:
signed char
<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedByte">
  </xsd:restriction>
</xsd:simpletype>
All mapping levels:
char
<xsd:simpleType>
  <xsd:restriction base="xsd:short">
  </xsd:restriction>
</xsd:simpletype>
All mapping levels:
short
<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedShort">
  </xsd:restriction>
</xsd:simpletype>
All mapping levels:
unsigned short
<xsd:simpleType>
  <xsd:restriction base="xsd:integer">
  </xsd:restriction>
</xsd:simpletype>
All mapping levels:
char[33]
<xsd:simpleType>
  <xsd:restriction base="xsd:int">
  </xsd:restriction>
</xsd:simpletype>
All mapping levels:
int
<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedInt">
  </xsd:restriction>
</xsd:simpletype>
All mapping levels:
unsigned int
<xsd:simpleType>
  <xsd:restriction base="xsd:long">
  </xsd:restriction>
</xsd:simpletype>
All mapping levels:
long long
<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedLong">
  </xsd:restriction>
</xsd:simpletype>
All mapping levels:
unsigned long long
<xsd:simpleType>
  <xsd:restriction base="xsd:boolean">
  </xsd:restriction>
</xsd:simpletype>
All mapping levels:
bool

(C++ only)

short

(C only)

<xsd:simpleType>
  <xsd:list>
    <xsd:simpleType>
      <xsd:restriction base="xsd:int"/>
    </xsd:simpleType>
  </xsd:list>
</xsd:simpleType>

Mapping level 1.0: Not supported

Mapping level 1.1 and higher:
char[255]
<xsd:simpleType>
  <xsd:union memberTypes="xsd:int xsd:string"/>
</xsd:simpleType>

Mapping level 1.0: Not supported

Mapping level 1.1 and higher:
char[255]
<xsd:simpleType>
  <xsd:restriction base="xsd:base64Binary">
    <xsd:length value="z"/>
  </xsd:restriction>
</xsd:simpleType>
<xsd:simpleType>
  <xsd:restriction base="xsd:base64binary">
  </xsd:restriction>
</xsd:simpletype>
where the length is not defined
Mapping level 1.1 and below:
char[y]
where y =4×(ceil( z /3)). ceil( x ) is the smallest integer greater than or equal to x.
Mapping level 1.2 and higher:
char[z]
where the length is fixed.
char[16]

is the name of the container that stores the binary data when the length is not defined.

<xsd:simpleType>
  <xsd:restriction base="xsd:float">
  </xsd:restriction>
</xsd:simpletype>
Mapping level 1.1 and below:
char[32]
Mapping level 1.2 and higher:
float(*)
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 float data types with fixed precision alternatives.
<xsd:simpleType>
  <xsd:restriction base="xsd:double">
  </xsd:restriction>
</xsd:simpletype>
Mapping level 1.0 and below:
char[32]
Mapping level 1.2 and higher:
double(*)
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 double data types with fixed precision alternatives.