TOC PREV NEXT INDEX


List Type


An xsd:list type is used to model a space-separated list of values of a given type. This type is mapped to a linked-list type if its length is unbounded, or an array type if its length is bounded. The built-in OSRTDList type (run-time doubly linked list) is the type used for repeating sequences such as this. This list type can be used with the rtxDList run-time functions for building and manipulating lists. See the Doubly-Linked List Utility Functions section for more details.
In the case of C++, the built-in OSRTDListClass or OSRTObjListClass type is used. These classes extend the C OSRTDList structure and add constructors and methods for adding, finding, and removing items from the list. The generated C++ code contains overloaded versions of these methods that correspond to the specific type of the element within the list.
The general C and C++ mapping for an XSD list type is as follows:
Unbounded Case
XSD type:
<xsd:simpleType name="TypeName">
 
   <xsd:list itemType="Type"/>
 
</xsd:simpleType>
 
 
Generated C code:
typedef OSRTDList TypeName;
 

 
Generated C++ code:
class TypeName : public OSRTDListClass {
 
   ...
 
} ;
 

 


Bounded Case
XSD type:
<xs:simpleType name="TypeName">
 
    <xs:restriction>
 
      <xs:simpleType>
 
        <xs:list itemType="type"/>
 
      </xs:simpleType>
 
      <xs:length value="length"/>
 
    </xs:restriction>
 
</xs:simpleType>
 
Generated C code:
typedef struct TypeName {
 
   OSUINT32 n;
 
   TYPE elem[length];
 
} typeName;
 

 
Generated C++ code:
class TypeName : public OSRTBaseType {
 
   OSUINT32 n;
 
   TYPE elem[length];
 
   ...
 
} ;
 

 




The one exception to this mapping occurs when the referenced item type is an enumeration. In this case, a structure is generated with each enumerated item represented as a single bit. This is a more compact structure that is easier to work with for specifying enumerated items and for validation to make sure there are no duplicates in the list. The mapping for this special case is as follows:
XSD type:
<xsd:simpleType name="EnumType">
 
   <xsd:restriction base="xsd:string">
 
      <xsd:enumeration value="enum1"/>
 
      <xsd:enumeration value="enum2"/>
 
      ...
 
      <xsd:enumeration value="enumN"/>
 
   </xsd:restriction>
 
</xsd:simpleType>
 

 
<xsd:simpleType name="TypeName">
 
   <xsd:list itemType="EnumType"/>
 
</xsd:simpleType>
 

 
Generated C code:
typedef struct TypeName {
 
   unsigned enum1Bit : 1;
 
   unsigned enum2Bit : 1;
 
   ...
 
   unsigned enumNBit : 1;
 
   OSRTDList* _extItems;
 
} TypeName;
 

 
Generated C++ code:
class TypeName : public OSRTBaseType {
 
public:
 
   unsigned enum1Bit : 1;
 
   unsigned enum2Bit : 1;
 
   ...
 
   unsigned enumNBit : 1;
 
   OSRTDListClass* _extItems;
 

 
   ...
 
} ;
 

 


Each of the bit fields in this type represents a declared enumeration item in the XSD definition. The _extItems field is added for extensibility purposes (i.e. if an unknown item is received it is added to this list). This construct will be used if a declared enumerated type is referenced (as is the case above) or if the list type contains an anonymous type with an enumeration list.

Copyright © Objective Systems 2002-2008
This document may be distributed in any form, electronic or otherwise, provided that it is distributed in its entirety and that the copyright and this notice are included.

Objective Systems, Inc.

55 Dowlin Forge Road
Exton, Pennsylvania 19341
http://www.obj-sys.com
Phone: (484) 875-9841
Toll-free: (877) 307-6855 (US only)
Fax: (484) 875-9830
info@obj-sys.com

TOC PREV NEXT INDEX