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

Re: Atleast one element should be present in ComplexType.

From: Jacob George <jacobg@atinav.com>
Date: Wed, 2 Apr 2003 13:48:19 +0530
Message-ID: <011a01c2f8f0$78652810$9a00000a@jacobg>
To: "Avula, Raj" <ravula@firstam.com>
Cc: <xmlschema-dev@w3.org>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:36 GMT