
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.
In both cases, a special member variable named _xsiType is added to the generated code to identify the xsi:type attribute of the instance. This attribute is added to an encoded instance when encoding is done.
The general mapping is as follows:
<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> ... /* choice tag constants */ #define T_TypeName_elem1 1 #define T_TypeName_elem2 2 ... #define T_TypeName_elemN NOSUINT16 t; union { /* t = 1 */ Type1 elem1; /* t = 2 */ Type1 elem2; ... /* t = N */ TypeN elemN; } u; const OSUTF8CHAR* _xsiType; } TypeName;
| Copyright © Objective Systems 2002-2007 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 RoadExton, 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 |