
C Example
The following is a common example of a choice construct with a nested sequence. This allows element a or element b or both elements to be present in an XML instance of the type:
<xsd:complexType name="AOrBOrBothType"> <xsd:choice> <xsd:sequence> <xsd:element name="a" type="xsd:string"/> <xsd:element name="b" type="xsd:string" minOccurs="0"/> </xsd:sequence> <xsd:element name="b" type="xsd:string"/> </xsd:choice> </xsd:complexType>typedef struct AOrBOrBothType_1 { struct { unsigned bPresent : 1; } m; OSXMLSTRING a; OSXMLSTRING b; } AOrBOrBothType_1; /* choice tag constants */ #define T_AOrBOrBothType__seq1 1 #define T_AOrBOrBothType_b 2 typedef struct AOrBOrBothType { OSUINT16 t; union { /* t = 1 */ AOrBOrBothType_1 *_seq1; /* t = 2 */ OSXMLSTRING* b; } u; } AOrBOrBothType;
| 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 |