Groups
Creating a Group in an XML Schema
To create a new group:
1. Right-click the element for which you want to create a group in the XML navigator and select New > Group.
2. In the dialog box that opens, enter the name of the group.
3. Click Create.

The group creation dialog box varies according to the mode selected. To obtain all the properties of a group, you must select "XML Expertise Level", accessible from the
Tools menu of the schema editor.
Example
|
Diagram
|
Diagram
|
XML Document
|
|
!  |
<Paperback>
<Preface/>
<Chapter>
</Chapter>
...
<Epilog>
</Epilog>
</Paperback>
|
UML modeling
A group is represented by a class of the Schema Group stereotype.

Create a Class

Open its properties page.

Click the
Characteristics tab.

In the
stereotype field, select "Schema Group" .
Attribute Group Template
It is possible to define templates for attribute groups. This type of group does not contain any elements but contains a certain number of attributes and attribute subgroups. The concept of order does not exist for attribute groups.
These groups appear at schema level and are then reused within tag definitions by referencing. This avoids redundant definitions.
Element Group Template
As for attributes, it is possible to define element group templates. The aim is to avoid definition redundancy since inheritance between groups does not exist. These groups are defined at schema level. They contain element sub-groups (all, sequence, choice). They are referenced within tag definitions.
Ordering the Elements in a Group
The elements of a group can be ordered.
To order the elements:

Select the group in the schema editor navigator.

In the right part, select the
Characteristics tab.

In the
Order list box, select one of the following values using the arrow .
• "All": type elements appear zero or one times and in any order. "All" groups are only authorized at the highest level of a type and must appear alone. In addition, they can only contain elements.
• "Sequence": the elements must appear in the order specified by the Order link attribute between the Schema Group class and the association roles.
• "Choice": only one of the elements appears.
or:

In the schema editor, right-click the group to be ordered and select
Type properties.
Its dialog box appears.

In the
Generation tab, in the generation language subtab (
XSD) complete the
XDD Order list box using the arrow.
The value of the XDD Order parameter and the multiplicities of the different sub-elements define in what order the sub-elements appear within the group, and how often.
The following table gives some examples:
|
XDD Order
|
Multiplicity for A
|
Multiplicity for B
|
Multiplicity for C
|
Comment
|
Example
|
|
Choice
|
1
|
*
|
1
|
One A tag or (0 or more B tags) or one C tag
|
<X>
<A/>
</X>
|
|
Sequence
|
1
|
1
|
*
|
One A tag followed by one B tag followed by 0 or more C tags.
|
<X>
<A/> <B/> <C/> <C/>
</X>
|
|
all
|
1
|
1
|
1
|
One tag of each in any order.
|
<X>
<B/> <C/> <A/>
</X>
|
UML modeling

Display the properties dialog box for a class of the
Schema Group stereotype and proceed as described above.
Using a Group
Groups can be used as classes when declaring a set.
In XSD, a special tag is created (<sequence>, <choice>, <all>).
Example
Tags defined for the paperback class declare a group instance (multiplicity of 1). Then, to avoid needlessly overcrowding the schema package, the successive chapters class is declared locally to the paperback class (symbol ().

Local: this characteristic determines whether the group is created locally to the tag definition or group containing the element, or whether it is created globally (at namespace level).
XSD
<xsd:ComplexType name="Book">
<xsd:sequence>
<xsd:element name="Summary" type='Summary' minOccurs="1" maxOccurs="1"/>
<xsd:sequence minOccurs="1" maxOccurs="1">
<xsd:element name = 'Preface' type="Preface" minOccurs="0" maxOccurs="1"/>
<xsd:element name = 'Chapter' type="Chapter" minOccurs="0" maxOccurs="*"/>
<xsd:element name = 'Epilogue' type="Epilogue" minOccurs="0" maxOccurs="1"/>
</xsd:sequence>
</xsd:sequence>
<xsd:attribute name="ISBN" type="xsd:ID" use="required"/>
<xsd :attribute name="Author" type="xsd:IDREF" use="required"/>
<xsd:attribute name="Collection" type="xsd:IDREFS" />
<xsd:attribute name="category" type="category" use="required"/>
</xsd:ComplexType>