C/C++ and XML Schema mapping

Utility programs DFHLS2WS and DFHWS2LS support mappings between C and C++ data types and the XML Schema definitions that are included in each Web service description.

C and C++ to XML schema

C and C++ names are converted to XML names according to the following rules:
  1. Characters that are not valid in XML element names are replaced with 'X'.

    For example, monthly-total becomes monthlyXtotal.

  2. Start of changeDuplicate names are made unique by the addition of one or more numeric digits.

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

    End of change
DFHLS2WS maps C and C++ data types to schema elements according to the following table. C and C++ types that are not shown in the table are not supported by DFHLS2WS. The following restrictions also apply:
  • Header files must contain a top level struct instance.
  • You cannot declare a structure type that contains itself as a member
  • The following C and C++ data types are not supported:
    • decimal
    • long double
    • wchar_t (C++ only)
  • The following are ignored if they are present in the header file.
    Storage class specifiers:
    • auto
    • register
    • static
    • extern
    • mutable
    Qualifiers
    • const
    • volatile
    • _Export (C++ only)
    • _Packed (C only)
    Function specifiers
    • inline (C++ only)
    • virtual (C++ only)
    Initial values
  • The header file must not contain the following:
    • Unions
    • Class declarations
    • Enumeration data types
    • Pointer type variables
    • Template declarations
    • Predefined macros - that is, macros with names which start and end with two underscore characters (__)
    • The line continuation sequence (a \ symbol that is immediately followed by a newline character)
    • Prototype function declarators
    • Preprocessor directives
    • Bit fields
    • The __cdecl (or _cdecl) keyword (C++ only)
  • The application programmer is required to use a 32 bit compiler to ensure that an int will map to 4 bytes.
  • The following C++ reserved keywords are not supported:
    • explicit
    • using
    • namespace
    • typename
    • typeid
C and C++ data type Schema simpleType
char[z]
<xsd:simpleType>
  <xsd:restriction base="xsd:string">
    <xsd:length value="z"/>
  </xsd:restriction>
</xsd:simpletype>
char
<xsd:simpleType>
  <xsd:restriction base="xsd:byte">
  </xsd:restriction>
</xsd:simpletype>
unsigned char
<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedByte">
  </xsd:restriction>
</xsd:simpletype>
short
<xsd:simpleType>
  <xsd:restriction base="xsd:short">
  </xsd:restriction>
</xsd:simpletype>
unsigned short
<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedShort">
  </xsd:restriction>
</xsd:simpletype>

int
long

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

unsigned int
unsigned long

<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedInt">
  </xsd:restriction>
</xsd:simpletype>
long long
<xsd:simpleType>
  <xsd:restriction base="xsd:long">
  </xsd:restriction>
</xsd:simpletype>
unsigned long long
<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedLong">
  </xsd:restriction>
</xsd:simpletype>

bool

(C++ only)
<xsd:simpleType>
  <xsd:restriction base="xsd:boolean">
  </xsd:restriction>
</xsd:simpletype>

float

Supported at mapping level 1.2

<xsd:simpleType>
  <xsd:restriction base="xsd:float">
  </xsd:restriction>
</xsd:simpletype>

double

Supported at mapping level 1.2

<xsd:simpleType>
  <xsd:restriction base="xsd:double">
  </xsd:restriction>
</xsd:simpletype>

XML Schema to C and C++

The CICS® Web services assistant generates 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 a leading 'X' is inserted.

    For example, 6monthlysummary becomes X6monthlysummary.

  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 two 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.

    Start of changeFor more information, see Variable arrays of elements.End of change

  6. Start of changeFor attributes, the previous rules are applied to the element name. The prefix attr_ is added to the element name, and this 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.

    End of change
The total length of the resulting name is 57 characters or less.
DFHWS2LS maps schema elements to C and C++ data types according to the following table. The following rules also apply:Start of changeEnd of change
Start of change
Schema simpleType Mapping level 1.0 and 1.1 Mapping level 1.2
<xsd:simpleType>
  <xsd:restriction base="xsd:anyType">
  </xsd:restriction>
</xsd:simpleType>

Not supported

Not supported

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

char[255]

Supported at mapping level of 1.1

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

char[z]

char[z]

<xsd:simpleType>
  <xsd:restriction base="xsd:type">
	</xsd:restriction>
</xsd:simpleType>
where type is one of:
  • duration
  • date
  • dateTime
  • time
  • gDay
  • gMonth
  • gYear
  • gMonthDay
  • gYearMonth

char[32]

char[32]

<xsd:simpleType>
  <xsd:restriction base="xsd:byte">
  </xsd:restriction>
</xsd:simpletype>

signed char

signed char

<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedByte">
  </xsd:restriction>
</xsd:simpletype>

char

char

<xsd:simpleType>
  <xsd:restriction base="xsd:short">
  </xsd:restriction>
</xsd:simpletype>

short

short

<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedShort">
  </xsd:restriction>
</xsd:simpletype>

unsigned short

unsigned short

Start of change
<xsd:simpleType>
  <xsd:restriction base="xsd:integer">
  </xsd:restriction>
</xsd:simpletype>
End of change
Start of change

char[33]

End of change
Start of change

char[33]

End of change
<xsd:simpleType>
  <xsd:restriction base="xsd:int">
  </xsd:restriction>
</xsd:simpletype>

int

int

<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedInt">
  </xsd:restriction>
</xsd:simpletype>

unsigned int

unsigned int

<xsd:simpleType>
  <xsd:restriction base="xsd:long">
  </xsd:restriction>
</xsd:simpletype>

long long

long long

<xsd:simpleType>
  <xsd:restriction base="xsd:unsignedLong">
  </xsd:restriction>
</xsd:simpletype>

unsigned long long

unsigned long long

<xsd:simpleType>
  <xsd:restriction base="xsd:boolean">
  </xsd:restriction>
</xsd:simpletype>

bool (C++ only)
short (C only)

bool (C++ only)
char (C only)

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

char[255]

Supported at mapping level 1.1

char[255]

<xsd:simpleType> 
	<xsd:union memberTypes="xsd:int xsd:string"/>
</xsd:simpleType>

char[255]

Supported at mapping level 1.1

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

char[y]

where y =4×(ceil(z/3)). ceil(x) is the smallest integer greater than or equal to x

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>

char[32]

float(*)

<xsd:simpleType>
  <xsd:restriction base="xsd:double">
  </xsd:restriction>
</xsd:simpletype>

char[32]

double(*)

End of change