Stylus Studio XML Editor

Table of contents

Appendices

3.8 Model Groups

Model Groups

When the [children] of element information items are not constrained to be empty or by reference to a simple type definition ([Simple Type Definitions]), the sequence of element information item [children] content may be specified in more detail with a model group. Because the [term] property of a particle can be a model group, and model groups contain particles, model groups can indirectly contain other model groups; the grammar for content models is therefore recursive.

NOTE: 
<xs:all>
 <xs:element ref="cats"/>
 <xs:element ref="dogs"/>
</xs:all>

<xs:sequence>
 <xs:choice>
  <xs:element ref="left"/>
  <xs:element ref="right"/>
 </xs:choice>
 <xs:element ref="landmark"/>
</xs:sequence>

XML representations for the three kinds of model group, the third nested inside the second.

The Model Group Schema Component[top]

The Model Group Schema Component

The model group schema component has the following properties:

[Model Group]

specifies a sequential (sequence), disjunctive (choice) or conjunctive (all) interpretation of the [particles]. This in turn determines whether the element information item [children] valid by the model group must:

  • (sequence) correspond, in order, to the specified [particles];

  • (choice) corresponded to exactly one of the specified [particles];

  • (all) contain all and only exactly zero or one of each element specified in [particles]. The elements can occur in any order. In this case, to reduce implementation complexity, [particles] is restricted to contain local and top-level element declarations only, with [p-min_occurs]=0 or 1, [p-max_occurs]=1.

When two or more particles contained directly or indirectly in the [particles] of a model group have identically named element declarations as their [term], the type definitions of those declarations must be the same. By 'indirectly' is meant particles within the [particles] of a group which is itself the [term] of a directly contained particle, and so on recursively.

See [Annotations] for information on the role of the [amg-annotation] property.

XML Representation of Model Group Schema Components[top]

XML Representation of Model Group Schema Components

The XML representation for a model group schema component is either an [all], a [choice] or a [sequence] element information item. The correspondences between the properties of those information items and properties of the component they correspond to are as follows:

Each of the above items corresponds to a particle containing a model group, with properties as follows (unless minOccurs=maxOccurs=0, in which case the item corresponds to no component at all):

[The Particle Schema Component][The Model Group Schema Component]

Constraints on XML Representations of Model Groups[top]

Constraints on XML Representations of Model Groups Model Group Representation OK

In addition to the conditions imposed on [all], [choice] and [sequence] element information items by the schema for schemas, the corresponding particle and model group must satisfy the conditions set out in [Constraints on Model Group Schema Components] and [Constraints on Particle Schema Components].

Model Group Validation Rules[top]

Model Group Validation Rules Element Sequence Valid

Define a partition of a sequence as a sequence of sub-sequences, some or all of which may be empty, such that concatenating all the sub-sequences yields the original sequence.

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

  1. ifthe [compositor] is sequence

    thenthere must be a partition of the sequence into n sub-sequences where n is the length of [particles] such that each of the sub-sequences in order is valid with respect to the corresponding particle in the [particles] as defined in [Element Sequence Locally Valid (Particle)].

  2. ifthe [compositor] is choice

    thenthere must be a particle among the [particles] such that the sequence is valid with respect to that particle as defined in [Element Sequence Locally Valid (Particle)].

  3. ifthe [compositor] is all

    thenthere must be a partition of the sequence into n sub-sequences where n is the length of [particles] such that there is a one-to-one mapping between the sub-sequences and the [particles] where each sub-sequence is valid with respect to the corresponding particle as defined in [Element Sequence Locally Valid (Particle)].

Nothing in the above should be understood as ruling out groups whose [particles] is empty: although no sequence can be valid with respect to such a group whose [compositor] is choice, the empty sequence is valid with respect to empty groups whose [compositor] is sequence or all.

NOTE: 

The above definition is implicitly non-deterministic, and should not be taken as a recipé for implementations. Note in particular that when [compositor] is all, particles is restricted to a list of local and top-level element declarations (see [Constraints on Model Group Schema Components]). A much simpler implementation is possible than would arise from a literal interpretation of the definition above; informally, the content is valid when each declared element occurs exactly once (or at most once, if [p-min_occurs] is 0), and each is valid with respect to its corresponding declaration. The elements can occur in arbitrary order.

Model Group Information Set Contributions[top]

Model Group Information Set Contributions

None as such.

Constraints on Model Group Schema Components[top]

Constraints on Model Group Schema Components

All model groups (see [Model Groups]) must satisfy the following constraints.

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

  2. Circular groups are disallowed. That is, within the [particles] of a group there must not be at any depth a particle whose [term] is the group itself.

All Group Limited

When a model group has [compositor] all

    1. It appears as the model group of a model group definition.

    2. It appears in a particle with [p-min_occurs]=[p-max_occurs]=1, and that particle must be part of a pair which constitutes the [content_type] of a complex type definition.

  1. The [p-max_occurs] of all the particles in the [particles] of the group must be 0 or 1.

Element Declarations Consistent

If the [particles] contains, either directly, indirectly (that is, within the [particles] of a contained model group, recursively) or implicitly contains two or more element declaration particles with the same [e-name] and [e-target_namespace], then all their type definitions must be the same top-level definition, that is,

  1. all their [type_definition]s must have a non-absent name.

  2. all their [type_definition]s must have the same name.

  3. all their [type_definition]s must have the same target namespace.

A list of particles implicitly contains an element declaration if a member of the list contains that element declaration in its substitution group.

Unique Particle Attribution

A content model must be formed such that during valid of an element information item sequence, the particle contained directly, indirectly or implicitly contains therein with which to attempt to valid each item in the sequence in turn can be uniquely determined without examining the content or attributes of that item, and without any information about the items in the remainder of the sequence.

NOTE: 

This constraint reconstructs for XML Schema the equivalent constraints of [ref-xml] and SGML. Given the presence of element substitution groups and wildcards, the concise expression of this constraint is difficult, see [Analysis of the Unique Particle Attribution Constraint (non-normative)] for further discussion.

NOTE: 

Because locally-scoped element declarations may or may not have a [e-target_namespace], the scope of declarations is not relevant to enforcing either of the two preceding constraints.

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

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 [p-min_occurs] and the sum of the [p-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 [p-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 [p-max_occurs] of the particle itself is unbounded, otherwise the product of the particle's [p-max_occurs] and the sum of the [p-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]).

Effective Total Range (choice)

The effective total range of a particle whose [term] is a group whose [compositor] is choice is a pair of minimum and maximum, as follows:

minimum

The product of the particle's [p-min_occurs] and the minimum of the [p-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 [p-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 [p-max_occurs] of the particle itself is unbounded, otherwise the product of the particle's [p-max_occurs] and the maximum of the [p-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]).