TOC PREV NEXT INDEX


Derivations


The derivations type is a special type generated by the XBinder compiler that collects all possible alternatives for XSD complexContent types. Its purpose is to allow handling of XML instances in which the type of the content is not known until run-time and is identified through the special xsi:type attribute. For C, it is similar to a CHOICE construct in that it contains a union of all possible alternatives. For C++, a single base element is generated that uses inheritance and polymorphism as the mechanism to identify derived alternatives.

The general mapping is as follows:
XSD type:
<xsd:complexType name="TypeName1">
 
   <xsd:complexContent>
 
      <xsd:extension base="BaseType">
 
         ...
 
      </xsd:extension>
 
   </xsd:complexContent>
 
</xsd:complexType>
 

 
<xsd:complexType name="TypeName2">
 
   <xsd:complexContent>
 
      <xsd:extension base="BaseType">
 
         ...
 
      </xsd:extension>
 
   </xsd:complexContent>
 
</xsd:complexType>
 
...
 
Generated C code:
/* choice tag constants */
 
#define T_TypeName_elem1	 1
 
#define T_TypeName_elem2	 2
 
...
 
#define T_TypeName_elemN	 N
 

 
typedef struct BaseType_derivations {
 
   OSUINT16 t;
 
   union {
 
      /* t = 1 */
 
      Type1 elem1;
 
      /* t = 2 */
 
      Type1 elem2;
 
      ...
 
      /* t = N */
 
      TypeN elemN;
 
   } u;
 
   const OSUTF8CHAR* _xsiType;
 
} TypeName;
 
 
Generated C++ code:
class BaseType_derivations : 
 
public OSXSDComplexType 
 
{
 
   (no content - abstract interface only)
 
   ...
 
} ;
 
 



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