HOPEX UML : HOPEX XML Schemas : XSD Generation : XSD: Type Definitions
   
XSD: Type Definitions
 
XSD: Generation Parameters for a Type Class
XSD: Type Inheritance
Simple types
Complex types
In general, UML classes are used to define the various elements in the vocabulary of a namespace, including attributes, elements, model groups, and attribute groups.
Aside from nested classes and associative classes, a class defining a type is generally connected to a schema class by the "XML Document Definition Root" leg. Otherwise, it is considered as belonging globally to the namespace and is therefore generated in all schemas of the namespace.
In the type definitions, XSD offers the ability to define complex types (complexType) and simple types (simpleType).
A class used as a type definition should not be of the "XML Document Definition" stereotype (reserved for schema classes) or of the "Schema group" stereotype (reserved for classes that define groups).
Associative classes are only taken into account in associations used to specify the existence of sub-elements in a type, meaning compositions. In this case, we consider the element to be of the type defined by the associative class and that this is derived from the component class.
XSD: Generation Parameters for a Type Class
You can specify the generation parameters for a type in the XSD tab of its Properties dialog box:
XSD Name: name of the type in the context of XSD generation. If this is not specified, the name of the class is used.
XSD Id: value of the "id" attribute.
XSD BlockExtension and XSD BlockRestriction: are used to determine the value of the "block" attribute. The value of the "block" attribute is a combination of the "extension" and "restriction" values.
XSD FinalExtension, XSD FinalRestriction, XSD FinalList and XSD FinalUnion: allow defining the value of the "final" attribute. This value is a combination of the "restriction", "list", and "union" values if it is a simple type, and a combination of the "extension" and "restriction" values if it is a complex type.
XSD List: used for simple types, this parameter is used to define "inheritance by list". See "Inheritance by list".
XSD union: used for simple types, this parameter is used to define "inheritance by union".
XDD order: indicates the ordering constraint on the sub-elements. reference
XDD Text: specifies whether the type contains data other than sub-tags. The result is reflected in the "mixed" attribute.
XDD compulsory ID Attribute: this parameter is used together with XDD ID Attribute Name and XDD ID Attribute Required. It indicates the presence of an "ID" attribute.
XDD ID Attribute Name: used to indicate the name of the ID attribute generated if XDD compulsory ID Attribute is "yes".
XDD ID Attribute Required: used to specify whether the attribute must be present in the document instance.
XSD: Type Inheritance
Simple types
Simple types are used to define the data that are contained either in attributes or in tags.
<tag attribute="data"/>
<tag>data</tag>
A simple type can be derived from another simple type. If a class is derived from another class representing a complex type, the derived class is interpreted as being of a complex type.
*Classes of the expression stereotype are generated as classes deriving from a simple type, and the primitive type is identified by the class connected by the "UML primitive type of expression" leg.??
Three forms of inheritance are possible for simple types:
Inheritance by restriction
It is possible to create a simple type from another simple type by imposing restrictions (on the size of the data, on the possible values, etc.). See “Restriction definition (facets)", page 53.
Inheritance by list
You can create a type that designates a list of values of a certain type. See “"List" type definition", page 54.
Inheritance by union
You can create types representing a grouping of different types. See “Union definition", page 50.
Complex types
Complex types define the content of tags (declared with the "element" tag) in terms of data, sub-tags, and attributes.
Similarly to simple types, complex types can benefit from inheritance. You can either extend or restrict their content.
A complex type can be derived from a complex type (<complexContent> or <simpleContent> if there is a restriction) or from a simple type (<simpleContent>).
Two forms of inheritance are possible:
Inheritance by extension
You can add sub-tags or attributes to an already existing type.
To extend the content of a complex type:
1. In the class diagram, click the Generalization button in the objects toolbar, and connect the class to the class representing the type you want to extend.
The new type is generated with a <complexContent> or <simpleContent> tag, in which the <elements> or <attributes> are generated inside the <extension> tag.
2. Right-click the generalization and open its Properties.
3. Select the Generation tab.
4. For XSD Inherited by restriction, select "extension".
Inheritance by restriction
You can restrict the content of a complex type. For example, you can change the constraints on its elements or attributes (such as the multiplicity).
To restrict the content of a complex type:
1. Use a generalization to connect the derived class to the class that you want to restrict.
2. Open the properties dialog box of the generalization.
3. Select the Generation tab.
4. For XSD Inherited by restriction, select "restriction".
In the content of the derived class, you need to add the attributes or create the compositions necessary to redefine the elements for which the constraints have changed.
As for the attributes, connect the redefined attribute to the basic attribute using the "Overloaded attribute" link.
Similarly, a role representing the new use of a sub-element is connected to the basic role by the "overloaded role" leg.
The other elements are not added to the class that will be generated as a restricted type: they will be generated automatically in the new type. The elements of the type are contained in a <restriction> tag, itself contained inside a <complexContent> or <simpleContent> tag.