Re: Derivation by restriction from <any>

Hi Dare,

> Upon investigating the W3C XML Schema Structures specification I've
> had some difficulty locating where it specifies that one-to-many
> particle derivations are acceptable. I would appreciate a pointer to
> where in the recommendation it mentions that this is possible. From
> what I've read[0] particle derivation is a one-to-one affair.

The specific derivation from this example is a derivation by
restriction from the base model group:

  <sequence>
    <any maxOccurs="unbounded"/>
  </sequence>

to the derived model group:

  <sequence>
    <element name="e1" type="string"/>
    <element name="e2" type="integer" minOccurs="0"/>
    <element name="e3" type="date" minOccurs="0"/>
  </sequence>

By the rules of the Schema Component Constraint: Particle Valid
(Restriction)
(http://www.w3.org/TR/xmlschema-1/#cos-particle-restrict), the
sequence in the base model group is "pointless" so the base model
group is equivalent to:

  <any maxOccurs="unbounded" />

The derivation we're looking at is therefore a restriction from an any
wildcard to a sequence model group, which falls under the purview of
Schema Component Constraint: Particle Derivation OK
(All/Choice/Sequence:Any -- NSRecurseCheckCardinality):

  For a group particle to be a ·valid restriction· of a wildcard
  particle all of the following must be true:
  1 Every member of the {particles} of the group is a ·valid
    restriction· of the wildcard as defined by Particle Valid
    (Restriction) (§3.9.6).
  2 The effective total range of the group, as defined by Effective
    Total Range (all and sequence) (§3.8.6) (if the group is all or
    sequence) or Effective Total Range (choice) (§3.8.6) (if it is
    choice) is a valid restriction of B's occurrence range as defined
    by Occurrence Range OK (§3.9.6).

     http://www.w3.org/TR/xmlschema-1/#rcase-NSRecurseCheckCardinality

So each of the element declarations in the derived model group (e1, e2
and e3) must be a valid restriction of the any in the base model group
(which they are).

As far as the one-to-many mapping is concerned, we have to look at the
effective total range of the sequence compared to the occurrence range
of the any wildcard. The effective total range of the sequence is
specified in the Schema Component Constraint: Effective Total Range
(all and sequence):

  The effective total range of a particle whose {term} is a group
  whose {compositor} is all or sequence is a pair of minimum and
  maximum, as follows:

  minimum
    The product of the particle's {min occurs} and the sum of the {min
    occurs} of every wildcard or element declaration particle in the
    group's {particles} and the minimum part of the effective total
    range of each of the group particles in the group's {particles}
    (or 0 if there are no {particles}).

  maximum
    unbounded if the {max occurs} of any wildcard or element
    declaration particle in the group's {particles} or the maximum
    part of the effective total range of any of the group particles in
    the group's {particles} is unbounded, or if any of those is
    non-zero and the {max occurs} of the particle itself is unbounded,
    otherwise the product of the particle's {max occurs} and the sum
    of the {max occurs} of every wildcard or element declaration
    particle in the group's {particles} and the maximum part of the
    effective total range of each of the group particles in the
    group's {particles} (or 0 if there are no {particles}).

                       http://www.w3.org/TR/xmlschema-1/#cos-seq-range

Following these rules, the effective total range of the sequence is a
minimum of 1 and the maximum of 3.

Now we have to look at Schema Component Constraint: Occurrence Range
OK:

  For a particle's occurrence range to be a valid restriction of
  another's occurrence range all of the following must be true:
  1 Its {min occurs} is greater than or equal to the other's {min
    occurs}.
  2 one of the following must be true:
    2.1 The other's {max occurs} is unbounded.
    2.2 Both {max occurs} are numbers, and the particle's is less
        than or equal to the other's.

                            http://www.w3.org/TR/xmlschema-1/#range-ok

The minimum of 1 is equal to the {min occurs} of 1 for the any
wildcard, and the any wildcard has a {max occurs} of unbounded.

Thus, the one-to-many mapping is just fine, I think.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Friday, 8 March 2002 05:06:46 UTC