Stylus Studio XML Editor

Table of contents

Appendices

3.9 Particles

Particles

As described in [Model Groups], particles contribute to the definition of content models.

NOTE: 
<xs:element ref="egg" minOccurs="12" maxOccurs="12"/>

<xs:group ref="omelette" minOccurs="0"/>

<xs:any maxOccurs="unbounded"/>
     

XML representations which all involve particles, illustrating some of the possibilities for controlling occurrence.

The Particle Schema Component[top]

The Particle Schema Component

The particle schema component has the following properties:

[Particle]

In general, multiple element information item [children], possibly with intervening character [children] if the content type is mixed, can be valid with respect to a single particle. When the [term] is an element declaration or wildcard, [p-min_occurs] determines the minimum number of such element [children] that can occur. The number of such children must be greater than or equal to [p-min_occurs]. If [p-min_occurs] is 0, then occurrence of such children is optional.

Again, when the [term] is an element declaration or wildcard, the number of such element [children] must be less than or equal to any numeric specification of [p-max_occurs]; if [p-max_occurs] is unbounded, then there is no upper bound on the number of such children.

When the [term] is a model group, the permitted occurrence range is determined by a combination of [p-min_occurs] and [p-max_occurs] and the occurrence ranges of the [term]'s [particles].

XML Representation of Particle Components[top]

XML Representation of Particle Components

Particles correspond to all three elements ([element] not immediately within [schema], [group] not immediately within [schema] and [any]) which allow minOccurs and maxOccurs attributes. These in turn correspond to two components in each case, a particle and its [term]. The appropriate mapping is described in [XML Representation of Element Declaration Schema Components], [XML Representation of Model Group Schema Components] and [XML Representation of Wildcard Schema Components] respectively.

Constraints on XML Representations of Particles[top]

Constraints on XML Representations of Particles

None as such.

Particle Validation Rules[top]

Particle Validation Rules Element Sequence Locally Valid (Particle)

For a sequence (possibly empty) of element information items to be locally valid with respect to a particle

  1. ifthe [term] is a wildcard

    then

    1. The length of the sequence must be greater than or equal to the [p-min_occurs].

    2. If [p-max_occurs] is a number, the length of the sequence must be less than or equal to the [p-max_occurs].

    3. Each element information item in the sequence must be valid with respect to the wildcard as defined by [Item Valid (Wildcard)].

  2. ifthe [term] is an element declaration

    then

    1. The length of the sequence must be greater than or equal to the [p-min_occurs].

    2. If [p-max_occurs] is a number, the length of the sequence must be less than or equal to the [p-max_occurs].

    3. For each element information item in the sequence

      1. The element declaration is local (i.e. its [e-scope] must not be global), its [e-abstract] is false, the element information item's [namespace name] is identical to the element declaration's [e-target_namespace] (where an absent [e-target_namespace] is taken to be identical to a [namespace name] with no value) and the element information item's [local name] matches the element declaration's [e-name].

        In this case the element declaration is the context-determined declaration for the element information item with respect to [Schema-Validity Assessment (Element)] and [Assessment Outcome (Element)].

      2. The element declaration is top-level (i.e. its [e-scope] is global), [e-abstract] is false, the element information item's [namespace name] is identical to the element declaration's [e-target_namespace] (where an absent [e-target_namespace] is taken to be identical to a [namespace name] with no value) and the element information item's [local name] matches the element declaration's [e-name].

        In this case the element declaration is the context-determined declaration for the element information item with respect to [Schema-Validity Assessment (Element)] and [Assessment Outcome (Element)].

      3. The element declaration is top-level (i.e. its [e-scope] is global), its [e-exact] does not contain substitution, the [local ] and [namespace name] of the element information item resolve to an element declaration, as defined in [QName resolution (Instance)] -- call this declaration the substituting declaration and the head declaration together with the particle's element declaration's [e-exact] is validly substitutable for the particle's element declaration as defined in [Substitution Group OK (Transitive)].

        In this case the head declaration is the context-determined declaration for the element information item with respect to [Schema-Validity Assessment (Element)] and [Assessment Outcome (Element)].

  3. ifthe [term] is a model group

    then

    1. There is a partition of the sequence into n sub-sequences such that n is greater than or equal to [p-min_occurs].

    2. If [p-max_occurs] is a number, n must be less than or equal to [p-max_occurs].

    3. Each sub-sequence in the partition is valid with respect to that model group as defined in [Element Sequence Valid].

NOTE: 

Clauses [c-pw] and [c-psg] do not interact: an element information item validatable by a declaration with a substitution group head in a different namespace is not validatable by a wildcard which accepts the head's namespace but not its own.

Particle Information Set Contributions[top]

Particle Information Set Contributions

None as such.

Constraints on Particle Schema Components[top]

Constraints on Particle Schema Components

All particles (see [Particles]) must satisfy the following constraints.

Particle Correct
  1. The values of the properties of a particle must be as described in the property tableau in [The Particle Schema Component], modulo the impact of [Missing Sub-components].

  2. If [p-max_occurs] is not unbounded, that is, it has a numeric value, then

    1. [p-min_occurs] must not be greater than [p-max_occurs].

    2. [p-max_occurs] must be greater than or equal to 1.

The following constraints define relations appealed to elsewhere in this specification.

Particle Valid (Extension)

For a particle (call it E, for extension) to be a valid extension of another particle (call it B, for base)

  1. They are the same particle.

  2. E's [p-min_occurs]=[p-max_occurs]=1 and its [term] is a sequence group whose [particles]' first member is a particle all of whose properties, recursively, are identical to those of B, with the exception of [annotation] properties.

The approach to defining a type by restricting another type definition set out here is designed to ensure that types defined in this way are guaranteed to be a subset of the type they restrict. This is accomplished by requiring a clear mapping between the components of the base type definition and the restricting type definition. Permissible mappings are set out below via a set of recursive definitions, bottoming out in the obvious cases, e.g. where an (restricted) element declaration corresponds to another (base) element declaration with the same name and type but the same or wider range of occurrence.

NOTE: 

The structural correspondence approach to guaranteeing the subset relation set out here is necessarily verbose, but has the advantage of being checkable in a straightforward way. The working group solicits feedback on how difficult this is in practice, and on whether other approaches are found to be viable.

Particle Valid (Restriction)

For a particle (call it R, for restriction) to be a valid restriction of another particle (call it B, for base)

  1. They are the same particle.

  2. depending on the kind of particle, per the table below, with the qualifications that

    1. Any top-level element declaration particle (in R or B) which is the [class_exemplar] of one or more other element declarations is treated as if it were a choice group whose [p-min_occurs] and [p-max_occurs] are those of the particle, and whose [particles] consists of one particle with [p-min_occurs] and [p-max_occurs] of 1 for the top-level element declaration and for each of the declarations in its substitution group.

    2. Any pointless occurrences of [sequence], [choice] or [all] are ignored, where pointlessness is understood as follows:

      [sequence]
      1. [particles] is empty.

        1. The particle within which this [sequence] appears has [p-max_occurs] and [p-min_occurs] of 1.

          1. The [sequence]'s [particles] has only one member.

          2. The particle within which this [sequence] appears is itself among the [particles] of a [sequence].

      [all]
      1. [particles] is empty.

      2. [particles] has only one member.

      [choice]
      1. [particles] is empty and the particle within which this [choice] appears has [p-min_occurs] of 0.

        1. The particle within which this [choice] appears has [p-max_occurs] and [p-min_occurs] of 1.

          1. The [choice]'s [particles] has only one member.

          2. The particle within which this [choice] appears is itself among the [particles] of a [choice].

    [NameAnd- TypeOK] NSCompat [Recurse- AsIfGroup] [Recurse- AsIfGroup] [RecurseAs- IfGroup] NSSubset Forbidden Forbidden Forbidden Forbidden [NSRecurse- CheckCardinality] Recurse Forbidden Forbidden Forbidden [NSRecurse- CheckCardinality] RecurseLax Forbidden Forbidden Forbidden [NSRecurse- CheckCardinality] [Recurse- Unordered] MapAndSum Recurse Forbidden

Occurrence Range OK

For a particle's occurrence range to be a valid restriction of another's occurrence range

  1. Its [p-min_occurs] is greater than or equal to the other's [p-min_occurs].

    1. The other's [p-max_occurs] is unbounded.

    2. Both [p-max_occurs] are numbers, and the particle's is less than or equal to the other's.

Particle Restriction OK (Elt:Elt -- NameAndTypeOK)

For an element declaration particle to be a valid restriction of another element declaration particle

  1. The declarations' [e-name]s and [e-target_namespace]s are the same.

  2. Either B's [nillable] is true or R's [nillable] is false.

  3. R's occurrence range is a valid restriction of B's occurrence range as defined by [Occurrence Range OK].

  4. either B's declaration's [e-value_constraint] is absent, or is not fixed, or R's declaration's [e-value_constraint] is fixed with the same value.

  5. R's declaration's [identity-constraint_definitions] is a subset of B's declaration's [identity-constraint_definitions], if any.

  6. R's declaration's [e-exact] is a superset of B's declaration's [e-exact].

  7. R's [type_definition] is validly derived given {extension, list, union} from B's [type_definition] as defined by [Type Derivation OK (Complex)] or [Type Derivation OK (Simple)], as appropriate.

NOTE: 

The above constraint on [type_definition] means that in deriving a type by restriction, any contained type definitions must themselves be explicitly derived by restriction from the corresponding type definitions in the base definition.

Particle Derivation OK (Elt:Any -- NSCompat)

For an element declaration particle to be a valid restriction of a wildcard particle

  1. The element declaration's [e-target_namespace] is valid with respect to the wildcard's [namespace_constraint] as defined by [Wildcard allows Namespace Name].

  2. R's occurrence range is a valid restriction of B's occurrence range as defined by [Occurrence Range OK].

Particle Derivation OK (Elt:All/Choice/Sequence -- RecurseAsIfGroup)

For an element declaration particle to be a valid restriction of a group particle (all, choice or sequence) a group particle of the variety corresponding to B's, with [p-min_occurs] and [p-max_occurs] of 1 and with [particles] consisting of a single particle the same as the element declaration must be a valid restriction of the group as defined by [Particle Derivation OK (All:All,Sequence:Sequence -- Recurse)], [Particle Derivation OK (Choice:Choice -- RecurseLax)] or [Particle Derivation OK (All:All,Sequence:Sequence -- Recurse)], depending on whether the group is all, choice or sequence.

Particle Derivation OK (Any:Any -- NSSubset)

For a wildcard particle to be a valid restriction of another wildcard particle

  1. R's occurrence range must be a valid restriction of B's occurrence range as defined by [Occurrence Range OK].

  2. R's [namespace_constraint] must be an intensional subset of B's [namespace_constraint] as defined by [Wildcard Subset].

Particle Derivation OK (All/Choice/Sequence:Any -- NSRecurseCheckCardinality)

For a group particle to be a valid restriction of a wildcard particle

  1. Every member of the [particles] of the group is a valid restriction of the wildcard as defined by [Particle Valid (Restriction)].

  2. The effective total range of the group, as defined by [Effective Total Range (] (if the group is all or sequence) or [Effective Total Range (] (if it is choice) is a valid restriction of B's occurrence range as defined by [Occurrence Range OK].

Particle Derivation OK (All:All,Sequence:Sequence -- Recurse)

For an all or sequence group particle to be a valid restriction of another group particle with the same [compositor]

  1. R's occurrence range is a valid restriction of B's occurrence range as defined by [Occurrence Range OK].

  2. There is a complete order-preserving functional mapping from the particles in the [particles] of R to the particles in the [particles] of B such that

    1. Each particle in the [particles] of R is a valid restriction of the particle in the [particles] of B it maps to as defined by [Particle Valid (Restriction)].

    2. All particles in the [particles] of B which are not mapped to by any particle in the [particles] of R are emptiable as defined by [Particle Emptiable].

NOTE: 

Although the valid semantics of an all group does not depend on the order of its particles, derived all groups are required to match the order of their base in order to simplify checking that the derivation is OK.

A complete functional mapping is order-preserving if each particle r in the domain R maps to a particle b in the range B which follows (not necessarily immediately) the particle in the range B mapped to by the predecessor of r, if any, where "predecessor" and "follows" are defined with respect to the order of the lists which constitute R and B.

Particle Derivation OK (Choice:Choice -- RecurseLax)

For a choice group particle to be a valid restriction of another choice group particle

  1. R's occurrence range is a valid restriction of B's occurrence range as defined by [Occurrence Range OK];

  2. There is a complete order-preserving functional mapping from the particles in the [particles] of R to the particles in the [particles] of B such that each particle in the [particles] of R is a valid restriction of the particle in the [particles] of B it maps to as defined by [Particle Valid (Restriction)].

NOTE: 

Although the valid semantics of a choice group does not depend on the order of its particles, derived choice groups are required to match the order of their base in order to simplify checking that the derivation is OK.

Particle Derivation OK (Sequence:All -- RecurseUnordered)

For a sequence group particle to be a valid restriction of an all group particle

  1. R's occurrence range is a valid restriction of B's occurrence range as defined by [Occurrence Range OK].

  2. There is a complete functional mapping from the particles in the [particles] of R to the particles in the [particles] of B such that

    1. No particle in the [particles] of B is mapped to by more than one of the particles in the [particles] of R;

    2. Each particle in the [particles] of R is a valid restriction of the particle in the [particles] of B it maps to as defined by [Particle Valid (Restriction)];

    3. All particles in the [particles] of B which are not mapped to by any particle in the [particles] of R are emptiable as defined by [Particle Emptiable].

NOTE: 

Although this clause allows reordering, because of the limits on the contents of all groups the checking process can still be deterministic.

Particle Derivation OK (Sequence:Choice -- MapAndSum)

For a sequence group particle to be a valid restriction of a choice group particle

  1. There is a complete functional mapping from the particles in the [particles] of R to the particles in the [particles] of B such that each particle in the [particles] of R is a valid restriction of the particle in the [particles] of B it maps to as defined by [Particle Valid (Restriction)].

  2. The pair consisting of the product of the [p-min_occurs] of R and the length of its [particles] and unbounded if [p-max_occurs] is unbounded otherwise the product of the [p-max_occurs] of R and the length of its [particles] is a valid restriction of B's occurrence range as defined by [Occurrence Range OK].

    NOTE: 

    This clause is in principle more restrictive than absolutely necessary, but in practice will cover all the likely cases, and is much easier to specify than the fully general version.

NOTE: 

This case allows the "unfolding" of iterated disjunctions into sequences. It may be particularly useful when the disjunction is an implicit one arising from the use of substitution groups.

Particle Emptiable

For a particle to be emptiable

  1. Its [p-min_occurs] is 0.

  2. Its [term] is a group and the minimum part of the effective total range of that group, as defined by [Effective Total Range (] (if the group is all or sequence) or [Effective Total Range (] (if it is choice), is 0.