
Example: Extension Elements
The following complexContent type contains a choice of two additional elements that were not defined in the base type (ProductType):
<xsd:complexType name="ShirtType"> <xsd:complexContent> <xsd:extension base="ProductType"> <xsd:choice> <xsd:element name="size" type="SizeType"/> <xsd:element name="color" type="ColorType"/> </xsd:choice> </xsd:extension> </xsd:complexContent> </xsd:complexType>#define T_ShirtType_1x2_size 1 #define T_ShirtType_1x2_color 2 typedef struct EXTERN ShirtType_1x2 { OSUINT16 t; union { /* t = 1 */ SizeType size; /* t = 2 */ ColorType color; } u; } ShirtType_1x2; typedef struct EXTERN ShirtType { ProductType base; ShirtType_1x2 ext; } ShirtType;class EXTERN ShirtType : public ProductType { public: // tag constants enum { T_size = 1, T_color = 2 } ; OSUINT16 t; union { /* t = 1 */ SizeType *size; /* t = 2 */ ColorType *color; } u; ... } ;
Objective Systems, Inc.102 Pickering Way, Suite #506Exton, 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 |