Re: min/max occurs facets on choice?

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.

Noah

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

--------------------------------------
Noah Mendelsohn
IBM Corporation
One Rogers Street
Cambridge, MA 02142
1-617-693-4036
--------------------------------------

Received on Friday, 13 February 2004 13:59:13 UTC