Re: Atleast one element should be present in ComplexType.

"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:

  (option+,data?|data)

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

ht
-- 
  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