Stylus Studio XML Editor

Table of contents

Appendices

3.7 Model Group Definitions

Model Group Definitions

A model group definition associates a name and optional annotations with a [Model Group]. By reference to the name, the entire model group can be incorporated by reference into a [term].

Model group definitions are provided primarily for reference from the [XML Representation of Complex Type Definitions] (see [complexType] and [group]). Thus, model group definitions provide a replacement for some uses of XML's [parameter entity] facility.

NOTE: 
<xs:group name="myModelGroup">
 <xs:sequence>
  <xs:element ref="someThing"/>
  . . .
 </xs:sequence>
</xs:group>

<xs:complexType name="trivial">
 <xs:group ref="myModelGroup"/>
 <xs:attribute .../>
</xs:complexType>

<xs:complexType name="moreSo">
 <xs:choice>
  <xs:element ref="anotherThing"/>
  <xs:group ref="myModelGroup"/>
 </xs:choice>
 <xs:attribute .../>
</xs:complexType>

A minimal model group is defined and used by reference, first as the whole content model, then as one alternative in a choice.

The Model Group Definition Schema Component[top]

The Model Group Definition Schema Component

The model group definition schema component has the following properties:

[Model Group Definition]

Model group definitions are identified by their [mg-name] and [mg-target_namespace]; model group identities must be unique within an XML Schema. See [References to schema components across namespaces] for the use of component identifiers when importing one schema into another.

Model group definitions per se do not participate in valid, but the [term] of a particle may correspond in whole or in part to a model group from a model group definition.

[model_group] is the [Model Group] for which the model group definition provides a name.

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

XML Representation of Model Group Definition Schema Components[top]

XML Representation of Model Group Definition Schema Components

The XML representation for a model group definition schema component is a [group] element information item. It provides for naming a model group for use by reference in the XML representation of complex type definitions and model groups. The correspondences between the properties of the information item and properties of the component it corresponds to are as follows:

If there is a name [attribute] (in which case the item will have [schema] or [redefine] as parent), then the item corresponds to a model group definition component with properties as follows:

[The Model Group Definition Schema Component]

Otherwise, the item will have a ref [attribute], in which case it corresponds to a particle component with properties as follows (unless minOccurs=maxOccurs=0, in which case the item corresponds to no component at all):

[Particle]

The name of this section is slightly misleading, in that the second, un-named, case above (with a ref and no name) is not really a named model group at all, but a reference to one. Also note that in the first (named) case above no reference is made to minOccurs or maxOccurs: this is because the schema for schemas does not allow them on the child of [group] when it is named. This in turn is because the [p-min_occurs] and [p-max_occurs] of the particles which refer to the definition are what count.

Given the constraints on its appearance in content models, an [all] should only occur as the only item in the [children] of a named model group definition or a content model: see [Constraints on Model Group Schema Components].

Constraints on XML Representations of Model Group Definitions[top]

Constraints on XML Representations of Model Group Definitions Model Group Definition Representation OK

In addition to the conditions imposed on [group] element information items by the schema for schemas, the corresponding model group definition, if any, must satisfy the conditions set out in [Constraints on Model Group Schema Components].

Model Group Definition Validation Rules[top]

Model Group Definition Validation Rules

None as such.

Model Group Definition Information Set Contributions[top]

Model Group Definition Information Set Contributions

None as such.

Constraints on Model Group Definition Schema Components[top]

Constraints on Model Group Definition Schema Components

All model group definitions (see [Model Group Definitions]) must satisfy the following constraint.

Model Group Definition Properties Correct

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