XML technologies / XML Schema / XML Schema element reference / xs:group (definition)
(Excerpt from “XML Schema” by Eric van der Vlist)
Global element-group declaration that can be referenced within the same schema or from others.
<xs:group
name = xs:NCName
>
Content: (xs:annotation?, (xs:all | xs:choice | xs:sequence))
</xs:group>May occur within: xs:redefine, xs:schema
Description
Element groups can be defined globally as containers reusable elsewhere in this schema or other schemas. These nearly semantics-free containers are flexible building blocks for defining local or global complex types.
Being global components, they can also encapsulate element definitions that cannot be global: unqualified elements in a schema with a target namespace, several same-named elements in one schema, elements that should not serve as document elements, or elements that should be redefinable in other schemas through xs:redefine.
Element groups can be redefined through xs:redefine by restriction, like restricting a complex type, or extension. This is more flexible than complex-type extension: the base group’s insertion point can be chosen, whereas derivation by extension always places new elements after the base type.
Any of the three compositors (xs:all, xs:sequence or xs:choice) can create an element group.
Restrictions
If a group is created with an xs:all compositor, it inherits all restrictions of xs:all. In other words, putting an xs:all compositor in a group does not remove the fundamental restrictions of xs:all.
Group definitions cannot be recursive.
Example
<xs:group name="name">
<xs:choice>
<xs:element ref="name"/>
<xs:sequence>
<xs:element ref="first-name"/>
<xs:element ref="middle-name" minOccurs="0"/>
<xs:element ref="last-name"/>
</xs:sequence>
</xs:choice>
</xs:group>Attributes
name
Group name, unqualified.
Copyright © 2003 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “XML Schema” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de