Model groups (XSD)
In XSD generation in MEGA, UML classes are used to create content, specifying the sequencing constraints when the content concerns sub-elements or groups of attributes if the class contains attributes.
When the class is used to construct a tag type, this content describes the sub-tags and sub-attributes that can be added to tags of this type.
You can also define content that does not result in tags in the document instance. This content is reusable in tag type definitions. You should use classes of the "schema group" stereotype to do this. See
"Generating XSD Groups".
Creating and Using a XSD model group
The model group classes must be components of the schema class and have the "schema group" stereotype.
In order to use a model group in a type (or in another group), you must create a composition between the type (or group) and the model group class. The role of the model group (non-composition role) contains information concerning this use (multiplicity for example).
In order to be able to use the model group in the XSD schema, you must reference it.
<xsd:group name="modelGroup">
<xsd:choice>
<xsd:element name="elmt" type="type1" minOccurs="1" maxOccurs="unbounded"/>
<xsd:element name="anotherElmt" type="anotherType"/>
</xsd:choice>
</xsd:group>
<xsd:complexType name="type2">
<xsd:sequence>
<xsd:group ref="modelGroup" minOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
To reference a model group:

Connect the role of the {type, model group} composition to that of the {schema, model group} composition. This is a link of "Referenced class" type.
<?xml version='1.0' encoding='ISO-8859-1'?>
<xsd:schema xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="element" type="type" minOccurs="0" maxOccurs="unbounded">
</xsd:element>
<xsd:attributeGroup name="modelgroupofdattributes">
<xsd:attribute name="Attrib" type="xsd:int" use="required">
</xsd:attribute>
</xsd:attributeGroup>
<xsd:complexType name="type" mixed="false">
<xsd:attribute name="id" use="required" type="xsd:ID"/>
<xsd:attributeGroup ref="modelgroupofdattributes"/>
</xsd:complexType>
</xsd:schema>
Classes of the "schema group" stereotype are used to model both the model groups of elements and the model groups of attributes. A model group class represents either a group of elements or a group of attributes, but not both.
When a "schema group" class contains one or more attributes, it is considered to be a group of attributes. This results in a model group of attributes for which the tag in the XSD schema is generated as <attributeGroup> (as are the references in the types).