Previous Table of Contents Next


7.5 Mapping for Complex XML Schema Types

   This section shows how complex XML schema types used in WSDL are mapped to CORBA.

7.5.1 Mapping for Sequence Group Element

   The sequence element in WSDL specifies that the child elements must appear in the order it is specified. It can be mapped to the OMG IDL struct datatype.

   Example:

   <!--WSDL -->

   <complexType name = “myStruct">

   <sequence>

   <element name="member_1" type="short"/>

   <element name="member_2" type="long"/>

   </sequence></complexType>

   // OMG IDL

   struct myStruct {short member_1:long member_2;

   };

7.5.2 Mapping for Choice Group Element

   The choice group element in WSDL allows only one of its children to appear in an instance. It can be mapped to discriminated union of OMG IDL with the discriminator type taken as IDL datatype long.

   Example:

   <!--WSDL --><complexType name="myUnion">

   <choice><element name="c" type="char"/><element name="s" type="short"/>

   </choice></complexType>

   // OMG IDL

   union myUnion switch (long) {case 1: char c;case 2: short s;

   };

7.5.3 Mapping for All Group Element

   The all element in WSDL specifies that the child elements do not need to appear in the order they are specified. It is mapped to the OMG IDL struct datatype, using the same rules as for a Sequence Group Element.

   The interaction translator is responsible to arrange the child elements in the proper order to be mapped to the corresponding IDL Struct.

   Example:

   <!--WSDL --><complexType name = "myAll">

   <all><element name="a_member_1" type="short"/><element name="a_member_2" type="long"/>

   </all></complexType>

   / OMG IDL

   struct myAll {

   short a_member_1:

   long a_member_2;

   };

7.5.4 Mapping Elements with Cardinality Constraints to IDL Sequence Member

   For use in the complex type mappings above, there is a special rule for mapping elements of an XML complex type, when those elements have minOccurs=0, or maxOccurs>1.

   If an element, which is a member of an XML complex type, has minOccurs=0 or has maxOccurs>1, that element will be mapped to an unnamed IDL Sequence.

   Example:

   <complexType name = "mesgInfoType">

    <xsd:sequence><xsd:element name="infoItem1" type="short"/>

   <xsd:element name="optInfo" type="myStruct" minOccurs="0"/> </xsd:sequence>

   </xsd:complexType>

   // OMG IDL

   struct mesgInfoType {

   short infoItem1:

   sequence<myStruct> optInfo;

   };

7.5.5 Mapping Attributes of Complex Type

   Attributes of sequence and all group complex types are mapped as additional members of the IDL struct.

   Complex types that use attribute groups have the attributes in that group mapped explicitly as members of the IDL struct, in the same order as if the attribute group definitions were expanded in line.

   If a Complex Type with simpleContent has one or more attributes, that complex type is mapped to an IDL Struct, with the first member of the IDL struct being of the simple type and having the name "value." The attributes are each mapped as additional members of the IDL Struct.

   If an XML schema attribute is defined anonymously (e.g., it uses an inline enumeration extension of string), the mapping shall generate an explicit IDL typedef using the "T_" prefix applied to the name of the attribute as the type name, just as for XML schema elements that are defined anonymously.

   Attributes of a choice group element are not mapped.

   If an attribute of the complex type is optional, then it is mapped to a struct member that is a sequence (just as if it were an element with minOccurs=0). Optional attributes are represented as IDL sequences in order to allow zero members, to cover the case of the attribute not being present.

   Example:

   <xsd:complexType> taggedShort <xsd:simpleContent> <xsd:extension base="xsd:short"> <xsd:attribute name="type" tag="xsd:string" use="optional"/> </xsd:extension> </xsd:simpleContent></xsd:complexType>

   // OMG IDL

   struct taggedShort {short value;sequence<wstring> tag;

   };