Mega Code Archive

 
Categories / XML Tutorial / XML Schema
 

You can further express occurrence behavior by using the minOccurs and maxOccurs attributes with either the choice element or t

<xsd:element name="middleName">   <xsd:complexType>    <xsd:choice maxOccurs="2">     <xsd:element name="initial" type="xsd:string"/>     <xsd:element name="name" type="xsd:string"/>    </xsd:choice>   </xsd:complexType> </xsd:element> The middleName element to contain one of two child elements: initial or name <middleName>   <initial>S</initial> </middleName> <middleName>   <name>Stolte</name> </middleName> To allow for this content model, we would have to use the choice element: <xsd:element name="middleName">   <xsd:complexType>    <xsd:choice>     <xsd:element name="initial" type="xsd:string"/>     <xsd:element name="name" type="xsd:string"/>    </xsd:choice>   </xsd:complexType> </xsd:element>