HOPEX UML : HOPEX XML Schemas : XSD Generation : Generating XSD Groups
   
Generating XSD Groups
 
Inherited Groups
Groups are used to define organizational constraints on the elements contained in a tag type.
According to the XSD specifications, all element declarations must be done within groups.
Generally during generation, the groups are inferred from the classes of the "schemaGroup" stereotype. This type of class is also used to represent model groups of elements and attributes.
In certain cases, the generated groups do not correspond to a class of the "schemaGroup" stereotype, but come from a class representing a type of element. The ordering constraint is specified by the XDD order generation parameter, displayed in the Properties dialog box of a class.
The different groups generated are:
all
An "all" content authorizes the elements of the type to 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.
*The number of times the element appears is indicated by the multiplicitiy declared on the element.
choice
A "choice" content results in the appearance of only one element among those declared in the group.
sequence
A "sequence" group requires the elements in the group to appear in the order in which they are declared in the group.
any
The "Any" group is a group that may contain any type of element. However, you may restrict the group of elements to a set of namespaces.
You can modify the XSD Any parameter in the group properties dialog box. The values available are:
"any": defines a group of any element type.
"anyAttribute": defines a group of any attribute type.
The manner in which groups are generated varies as follows:
If the group contains sub-elements, the group is generated following the defined order ("sequence", "choice" or "all").
If the group does not contain sub-elements, it is generated according to the value ("any" or "anyAttribute") you entered for the XSD Any parameter. Nothing is generated if the XSD Any parameter value is not defined.
Inherited Groups
It could be that a type B containing a group inherits from a type A containing a group of the same type. The associated generated XML schema will specifiy the inheritance notion.
However, in the instance document resolved by the schema, the type B element will not contain a group with concatenation of elements of A and B, but two groups: that defined in A then that defined in B.
<xsd:complexType name="A" mixed="false">
<xsd:sequence>
<xsd:element name="E1" type="E1" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="E2" type="E2" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:ID" use="required"/>
</xsd:complexType>
<xsd:complexType name="B" mixed="false">
<xsd:complexContent mixed="false">
<xsd:extension base="A">
<xsd:sequence>
<xsd:element name="E3" type="E3" minOccurs="0" maxOccurs="unbounded"/>
<xsd:element name="E4" type="E4" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
 
To obtain just one generated group, you must define a type B that does not inherit from type A but to which you add elements or attributes of A.