W3C home > Mailing lists > Public > xmlschema-dev@w3.org > November 2001

Re: Order of elements in a complex-type

From: Erik Beijnoff <erik@addsystems.com>
Date: Wed, 28 Nov 2001 15:31:07 +0100
To: "'maddy pawar'" <madhuvanti@hotmail.com>
Cc: <2kseema@sun20.datamatics.com>, <xmlschema-dev@w3.org>
Message-ID: <914A89E9F99D2C4B8E14FB8CC083F9BC739B@addex001.addsystems.com>
> Hi Seema,
> Simply replace the "xsd:sequence" with "xsd:all"
>
>> > How do I define it such that they may appear any number of
>times inside
>> Form  in any sequence ?
> ..insert  maxOccurs="unbounded"
> so it becomes:
>
>> > <xsd:complexType name="FormType" >
>> > <xsd:all>
>> > <xsd:element name="TextBox" type="TextBoxType" minOccurs="0"
>> maxOccurs="unbounded"/>
>> > <xsd:element name="TextArea" type="TextAreaType" minOccurs="0"
>> maxOccurs="unbounded"/>
>> > <xsd:element name="Header" type="HeaderType" minOccurs="0"
>> maxOccurs="unbounded"/>
>> > </xsd:all>
>> > </xsd:complexType>
>>

But as far as I know, the use of xs:all is quite restricted. One of the
restrictions is that you can only have maxOccurs="0" or maxOccurs="1" within
an xs:all, which eliminates the possibility to have an unrestricted number
of occurences of the three types within the FormType. Look at the problem
another way: The restriction in this case is a choice between three
different types of elements, and the choice can be done an unrestricted
number of times. Which gives us the schema below, which I think will do the
trick:

<xs:complexType name="FormType">
  <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element name="TextBox" type="TextBoxType"/>
    <xs:element name="TextArea" type="TextAreaType"/>
    <xs:element name="Header" type="HeaderType"/>
  </xs:choice>
</xs:complexType>


Best regards

Erik Beijnoff
Systems development

erik.beijnoff@addsystems.com
erik@beijnoff.com
Received on Wednesday, 28 November 2001 09:34:32 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 18:13:35 GMT