W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2002

Re: xs:all - why is minOccurs, maxOccurs restricted to "0" or "1" for child xs:element ?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Thu, 28 Mar 2002 09:07:19 +0000
Message-ID: <105471644458.20020328090719@jenitennison.com>
To: dbowen@es.com
CC: xmlschema-dev@w3.org
Hi Daniel,

> The problem is that minOccurs and maxOccurs for <xs:element> under
> <xs:all> have to be "0" or "1". It seems that the Schema's
> definition of <xs:group name="allModel"> ... is the part that's
> placing this restriction. Is there some fundamental reason why
> <xs:all> places such restrictions on the child element's minOccurs
> and maxOccurs? Or is there another way to define the schema to have
> the same effect that I'm after?

There's no way of expressing the constraints that you're after on a
content model using XML Schema alone. I'm not sure about the rationale
for this restriction, but I think it's something to do with the
semantics of an xs:all that contains particles with a maxOccurs
greater than one being ambiguous (does it mean that the elements of
the same type have to be next to each other or not? - in your case
not, in other cases it does).

There are two approaches that you could consider:

  - defining the schema to give a canonical ordering, and then having
    a script or stylesheet that reorders the instance documents into
    that canonical ordering prior to validation

  - defining the schema to give a loose definition of the content
    model (e.g. any number in any order) and then add rules using
    Schematron or another schema language to express the limitations
    on their occurrence

If you need help or further explanation on either of those, let us



Jeni Tennison
Received on Thursday, 28 March 2002 04:07:25 UTC

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