- From: Morris Matsa <mmatsa@us.ibm.com>
- Date: Tue, 8 Jan 2002 10:41:37 -0500
- To: "Seema" <2kseema@sun20.datamatics.com>
- Cc: <xmlschema-dev@w3.org>
maxOccurs="1" is the default so that doesn't change anything. What you were saying is "each time through the choice make sure that the Mandatory element appears exactly once." So it was ok for it to then appear again the next time through the choice, another exactly once. I don't know what the best way to accomplish your goal is, but I think this should work: <xsd:complexType name="FormType"> <xsd:sequence> <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:choice> <xsd:choice> <xsd:element name="Mandatory" type="EmptyType" /> <xsd:element name="Optional" type="EmptyType" /> </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:choice> </xsd:sequence> </xsd:complexType> You could also turn the repeated list of elements (TextBox, etc.) into a model group. "Seema" <2kseema@sun20.datamatics.com>@w3.org on 01/08/2002 07:52:38 AM Sent by: xmlschema-dev-request@w3.org To: <xmlschema-dev@w3.org> cc: Subject: 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 10:41:11 UTC