Re: Atleast one element should be present in ComplexType.

Hi Raj,
    I am relatively new to this XML stuff. So please correct me if I am wrong.

<xs:element name="REQUEST">
<xs:complexType>
<xs:choice>
<xs:group ref="FirstOption"/>
<xs:group ref="SecondOption"/>
</xs:choice>
</xs:complexType>
</xs:element>

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

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


                                                                                                                                                                                                                                                                                                            regards Jacob
  ----- Original Message ----- 
  From: Avula, Raj 
  To: 'xmlschema-dev@w3.org' 
  Sent: Wednesday, April 02, 2003 12:53 AM
  Subject: Atleast one element should be present in ComplexType.




  Hi,
  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.

  Thanks,
  Raj.

Received on Wednesday, 2 April 2003 03:18:08 UTC