Sample : Simple Sequence
Summary This sample shows an element containing a sequence of simple elements and attributes. Details The Element DVD contains a sequence of simple elements (simple because they are represented by primitives). All of these elements are required, and they must appear in the correct order. In addition the DVD element contains 2 attributes Genre and Cost. Genre is optional, Cost is Mandatory. Because Genre is optional, and contains primitive data, an IsValidGenre method is added to the generated DVD object. This allows you to determine if Genre was set or not. The generated classes take car of outputting the child elements in the correct order. |
SimpleSequence.xsd |
<?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="DVD"> <xs:complexType> <xs:sequence> <xs:element name="Title" type="xs:string"/> <xs:element name="Description" type="xs:string"/> <xs:element name="ReleaseDate" type="xs:date"/> </xs:sequence> <xs:attribute name="Genre" type="xs:string" use="optional"/> <xs:attribute name="Cost" type="xs:double" use="required"/> </xs:complexType> </xs:element> </xs:schema> |
Schema Diagrams |
|
Sample Name | Description | C++ | C# | Java | VB.Net | VB6 |
Missing Optional Elements | The sample demonstrates the element with some of the optional elements missing. Note Genre is an optional primitive, so we should check it using the IsValid flag before accessing it | Example | Example | Example | Example | Example |
Included Optional Elements | The sample demonstrates the element with all of the optional elements present. Note Genre is an optional primitive, so we should check it using the IsValid flag before accessing it | Example | Example | Example | Example | Example |
Main Menu |