Sample : Simple Choice
| Summary This sample shows an element containing a choice of simple elements. One and only one child element may be provided. Details The element AccountAdminRequest contains 3 child elements, CreateAccount, DeleteAccount and ChangeAccountPassword. Only one of these elements may be specified at a time, and one MUST be specified. All 3 of the child elements are represented in the generated code as classes (as opposed to primitive), despite being based on primitive types. This is because they all contain child attributes of there own. Elements with child elements or attributes must be represented as classes in the generated code. |
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="AccountAdminRequest">
<xs:complexType>
<xs:choice>
<xs:element name="CreateAccount">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Username" type="xs:string" use="required"/>
<xs:attribute name="Password" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="DeleteAccount">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="Username" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="ChangeAccountPassword">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:date">
<xs:attribute name="Username" type="xs:string" use="required"/>
<xs:attribute name="OldPassword" type="xs:string" use="required"/>
<xs:attribute name="NewPassword" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
|
![]() |
| Sample Name | Description | C++ | C# | Java | VB.Net | VB6 |
| Valid Choice | The sample demonstrates the element with ChangeAccountPassword element defined. | Example | Example | Example | Example | Example |
| Setting too many elements in a Choice | The sample demonstrates what happens when more than one item in a choice is set. | Example | Example | Example | Example | Example |
| Main Menu |