Problem in writing schema

Hi all,

I have a schema written for XML's that would represent a Form in html. The elements of the Form like textbox, textarea, etc would appear any no. of times in any order, however, there is a pair of tags, namely
<Optional> and
<Mandatory>

Out of these only one of them may appear, at a time in the form and only a single instance might appear.
How do I tackle this.
My present schema handles it in the following way :

<xsd:complexType name="FormType" >

 <xsd:choice minOccurs="0" maxOccurs="1" > 
  <xsd:choice minOccurs="0" maxOccurs="unbounded"> 
     <xsd:element name="TextBox" type="TextBoxType" />
     <xsd:element name="TextArea" type="TextAreaType" />
     <xsd:element name="Header" type="HeaderType"/>
     <xsd:element name="RadioButton" type="RadioButtonType" /> 
     <xsd:element name="SelectList" type="SelectListType" />
     <xsd:element name="Mandatory" type="EmptyType" maxOccurs="1"/>
   </xsd:choice>
   <xsd:choice minOccurs="0" maxOccurs="unbounded"> 
     <xsd:element name="TextBox" type="TextBoxType" />
     <xsd:element name="TextArea" type="TextAreaType" />
     <xsd:element name="Header" type="HeaderType"/>
     <xsd:element name="RadioButton" type="RadioButtonType" /> 
     <xsd:element name="SelectList" type="SelectListType" />
     <xsd:element name="Optional" type="EmptyType" maxOccurs="1"/>
   </xsd:choice>
  </xsd:choice>
  </xsd:complexType>


However, the condition that only one occurence of the tag (Optional or Mandatory) should appear is not satisfied while validating the XML with the schema.
Please suggest a suitable solution.

Thanks in advance
Seema

Received on Tuesday, 8 January 2002 07:55:01 UTC