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

RE: restricting minOccurs on a choice tag

From: Michael Kay <mhk@mhk.me.uk>
Date: Wed, 11 Aug 2004 09:01:37 +0100
To: "'Shane Lauf'" <srl01@uow.edu.au>
Cc: <xmlschema-dev@w3.org>
Message-ID: <E1Buo3n-0002hl-0u@frink.w3.org>

The following schema is reported as valid by Saxon, MSXML, XSV, and Xerces:

<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:did="did.uri"
targetNamespace="did.uri" 
elementFormDefault="qualified" attributeFormDefault="unqualified">

<element name="AbstractObject" type="did:AbstractObjectType"
abstract="true"/>

  <complexType name="AbstractObjectType">
    <complexContent>
      <extension base="did:AbstractObjectBaseType">
        <sequence>
          <choice minOccurs="0"> <!--***-->
            <element ref="did:AnotherObjectA"/>
            <element ref="did:AnotherObjectB"/>
          </choice>
        </sequence>
      </extension>
    </complexContent>
  </complexType>
  
<element name="ConcreteObject" substitutionGroup="did:AbstractObject"
type="did:ConcreteObjectType"/>

  <complexType name="ConcreteObjectType">
    <complexContent>
      <restriction base="did:AbstractObjectType">
        <sequence>
          <choice minOccurs="1"> <!--***-->
            <element ref="did:AnotherObjectA"/>
            <element ref="did:AnotherObjectB"/>
          </choice>
        </sequence>
      </restriction>
    </complexContent>
  </complexType> 
  
<element name="AnotherObjectA"/>
<element name="AnotherObjectB"/> 

<complexType name="AbstractObjectBaseType"/>


</schema>

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: xmlschema-dev-request@w3.org 
> [mailto:xmlschema-dev-request@w3.org] On Behalf Of Shane Lauf
> Sent: 11 August 2004 07:13
> To: xmlschema-dev@w3.org
> Subject: restricting minOccurs on a choice tag
> 
> 
> For the following part of a schema, which defines an 
> AbstractObject which
> has two possible child elements AnotherObjectA and 
> AnotherObjectB, is there
> a way that I can derive AbstractObject into a concrete 
> element Object where
> the minOccurs="0" is no longer on the choice - i.e. forcing 
> (restricting)
> Object to have *at least one* of the child objects present? I 
> know I can
> derive and restrict when the minOccurs="0" is on a single 
> element, but not
> sure about when it is on a choice.
> 
>   <element name="AbstractObject" type="did:AbstractObjectType"
> abstract="true"/>
>   <complexType name="AbstractObjectType">
>     <complexContent>
>       <extension base="did:AbstractObjectBaseType">
>         <sequence>
>           <choice minOccurs="0"> <!--***-->
>             <element ref="AnotherObjectA"/>
>             <element ref="AnotherObjectB"/>
>           </choice>
>         </sequence>
>       </extension>
>     </complexContent>
>   </complexType>
> 
> Regards,
> 
> Shane
> 
> 
> 
> 
Received on Wednesday, 11 August 2004 08:02:11 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:15:10 UTC