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

Re: min/max occurs facets on choice?

From: <noah_mendelsohn@us.ibm.com>
Date: Fri, 13 Feb 2004 13:42:13 -0500
To: "Ed Day" <eday@obj-sys.com>
Cc: xmlschema-dev@w3.org
Message-ID: <OF839BEA6B.69CE8D74-ON85256E39.006655E0@lotus.com>

Ed Day asks:

> We have a question regarding the use of min/max occurs
> facet on a choice construct.  The following would seem
> to be ambiguous:
>   <xs:complexType>
>    <xs:choice maxOccurs="unbounded">
>     <xs:element name="x" maxOccurs="10">

Coincidently, I think I explained most of how this works in a posting
earlier this month.  Please check [1] and see if it helps.

In summary, the answer is:  legal and not ambiguous, but you get the same
thing with the much simpler form:

     <xs:element name="x" maxOccurs="unbounded">

What may be confusing you is that schema does have limitations on certain
kinds of ambuity, notably:

<xs: sequence>
     <xs:element name="x" minOccurs="0">
     <xs:element name="x" minOccurs="0">
</xs: sequence>

This would accept no elements, one <x/> or a sequence of <x/>, <x/>.  The
problem is that, in the case of a single <x/>, it matches either of the two
so-called particles above, and that's not allowed.  The schema is illegal.

You might think your example is the same, but the difference is that for
all the repetition specified in your schema, there is only one explicit
reference to name="x".  So regardless of which way you try to match the
repeats, any <x/> that matches is surely surely against that one
"particle".  Your schema is indeed legal.  See [1] for how the repeat
matching is done.

Thank you.


[1] http://lists.w3.org/Archives/Public/xmlschema-dev/2004Feb/0025.html

Noah Mendelsohn
IBM Corporation
One Rogers Street
Cambridge, MA 02142
Received on Friday, 13 February 2004 13:59:13 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:04 UTC