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

xsd:group, minOccurs and xsd:choice

From: Nick Brook <nick.brook@3glab.com>
Date: Wed, 5 Feb 2003 14:50:24 -0000
Message-ID: <02b601c2cd25$ea1cb870$a700000a@tse>
To: <xmlschema-dev@w3.org>

Hi,

I'm trying to create a group with a choice of a number of elements. I want
the behaviour that at least one of the choice must exist, but can't find a
way in Schema to enforce this.
Here's a fragment of my schema:

  <xs:group name="actions">
    <xs:choice>
      <xs:element name="noaction">
      </xs:element>
      <xs:element name="writevar">
       </xs:annotation>
   </xs:choice>
  </xs:group>
...
  <xs:element name="change">
    <xs:complexType>
      <xs:sequence>
        ...some other elements...
        <xs:element name="do" minOccurs="1" maxOccurs="1">
          <xs:complexType mixed="false">
            <xs:group ref="actions" minOccurs="1" maxOccurs="unbounded"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

This allows the following:
<change>
  <do>
   </do>
</change>

Bizarrely it also allows:
<change>
  <do>
    <boguselement/>
  </do>
 </change>

I want the parser to flag both these examples as erroneous.

Any help would be much appreciated,

Thanks,

Nick Brook
3GLab
UK
Received on Wednesday, 5 February 2003 09:48:45 GMT

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