W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2003

Re: Atleast one element should be present in ComplexType.

From: Henry S. Thompson <ht@cogsci.ed.ac.uk>
Date: 02 Apr 2003 09:38:38 +0100
To: "Avula, Raj" <ravula@firstam.com>
Cc: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Message-ID: <f5bwuid47ld.fsf@erasmus.inf.ed.ac.uk>

"Avula, Raj" <ravula@firstam.com> writes:

> 	I have a complexType with two element children and I need to make
> sure that atleast one of that should be present.
> Here is the sample.
> 	<xs:element name="REQUEST">
> 		<xs:complexType>
> 			<xs:sequence>
> 				<xs:element ref="OPTION" minOccurs="0"
> maxOccurs="unbounded"/>
> 				<xs:element ref="DATA" minOccurs="0"/>
> 			</xs:sequence>
> 		</xs:complexType>
> 	</xs:element>
> In the above example, I need to make sure that atleast on among OPTION, DATA
> should be present.

There's no general way to do this, but in a simple case such as this
you can do it by hand:


 <xs:element name="REQUEST">
     <xs:element ref="OPTION" minOccurs="1" maxOccurs="unbounded"/>
     <xs:element ref="DATA" minOccurs="0"/>
     <xs:element ref="DATA"/>

  Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
                      Half-time member of W3C Team
     2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
     Fax: (44) 131 650-4587, e-mail: ht@cogsci.ed.ac.uk
       URL: http://www.ltg.ed.ac.uk/~ht/
 [mail really from me _always_ has this .sig -- mail without it is forged spam]
Received on Wednesday, 2 April 2003 03:38:40 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:10 UTC