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

Elements in any order

From: A Y <ay090@yahoo.com>
Date: Fri, 8 Aug 2003 08:48:23 -0700 (PDT)
Message-ID: <20030808154823.60466.qmail@web40301.mail.yahoo.com>
To: xmlschema-dev@w3.org

Hello, 

I am new to XML Schemas and I would like to define 
a schema for allowing two optional elements in any
order within a parent element. That is, all the
following XML documents should be valid.  

  <A>
     <B/>
     <B/>
  </A>

  <A>
     <C/>  <!-- only one of these can appear -->
  </A>

  <A>
     <B/>
     <B/> 
     <C/>
     <B/>
  </A>

  <A> 
    <C/>
    <B/>
    <B/>
  </A>

Although the following XML schema is not valid
(duplicate element names), it represents the class of
XML documents that are valid. 

<xsd:element name="A">
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element name="B" type="xsd:string"
                 minOccurs="0" maxOccurs="unbounded"/>
      <xsd:element name="C" type="xsd:string"
                 minOccurs="O" maxOccurs="1"/>
      <xsd:element name="B" type="xsd:string"
                 minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
  </xsd:complexType>
</xsd:element> 
     
I tried using <xsd:all> (errors with maxOccurs and
minOccurs) and <xsd:choice> (restricted to only one
<B> and <C>) with no success.

I really appreciate your help in this regard. 

Thanks, 
-Choudary. 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
Received on Friday, 8 August 2003 11:53:15 GMT

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