Contents > 7 SDMetrics Metamodel and XMI Transformation Files > 7.2 XMI Transformation Files > 7.2.2 XMI Transformations and Triggers
7.2.2 XMI Transformations and Triggers
To illustrate how to define XMI transformations and triggers, we
consider again the example of "operation" metamodel elements in
Section 7.1 "SDMetrics Metamodel". An operation model element has four attributes: an
id, a name, a context (operation owner),
and a visibility.
Below is the representation of an operation as expressed in an XMI 1.0
file. The places that contain information we are interested in are set
in boldface:
<Foundation.Core.Operation xmi.id="xmi.1632">
<!-- 1. operation id -->
<Foundation.Core.ModelElement.name>printStackTrace
<!-- 2. operation name -->
</Foundation.Core.ModelElement.name>
<Foundation.Core.ModelElement.visibility xmi.value="public"/>
<!-- 3. operation visibility -->
<Foundation.Core.ModelElement.isSpecification xmi.value="false"/>
<Foundation.Core.Feature.ownerScope xmi.value="instance"/>
<Foundation.Core.BehavioralFeature.isQuery xmi.value="false"/>
<Foundation.Core.Operation.isAbstract xmi.value="false"/>
<Foundation.Core.Feature.owner>
<Foundation.Core.Classifier xmi.idref="xmi.1605"/>
<!-- 4. operation context -->
</Foundation.Core.Feature.owner>
...
</Foundation.Core.Operation>
The following XMI transformation describes how the required information
is retrieved from an XMI 1.0 document:
<xmitransformation modelelement="operation"
xmipattern="Foundation.Core.Operation" recurse="true">
<trigger name="id" type="attrval" attr="xmi.id" />
<trigger name="name" type="ctext" src="Foundation.Core.ModelElement.name" />
<trigger name="visibility" type="cattrval"
src="Foundation.Core.ModelElement.visibility" attr="xmi.value"/>
<trigger name="context" type="gcattrval"
src="Foundation.Core.Feature.owner" attr="xmi.idref"/>
</xmitransformation>
The XMI transformation is enclosed within the
xmitransformation tags. The opening tag takes the following attributes:
- attribute modelelement (required): the SDMetrics
metamodel element for which this transformation is defined. In our
case, it's the operation.
- attribute xmipattern (required): the XMI element that
represents our UML element. In XMI 1.0, operations are
specified with the XMI element "Foundation.Core.Operation"
- attribute recurse (optional): is set to true if the
model element can serve as context for subelements. In our case,
operations can have parameters as subelements, so we set the attribute
to true (the XMI transformation for parameters is taken care of in a
separate XMI transformation).
- attributes requirexmiid and allowxmiidref (optional):
used to extract information from XMI elements that have no XMI ID of
their own. We'll discuss these attributes in Section 7.2.3.5 "Optional XMI ID".
- attribute condition (optional): specify a condition for
the attributes of the XMI element that must be fulfilled for this XMI
transformation to become effective. Conditional XMI transformations
will be discussed in Section 7.2.3.6 "Conditional XMI Transformations".
Each trigger in our transformation describes how to retrieve the
information for one SDMetrics metamodel attribute. Each trigger has
two required attributes:
- attribute type: indicates how the trigger retrieves
information from the XMI file. The type can be one of the
following: attrval, ctext, cattrval, gcattrval, constant, ignore,
and xmi2assoc.
- attribute name: the name of the SDMetrics metamodel
attribute to which this trigger pertains. In the above example, each
trigger refers to exactly one attribute of the operation metamodel
element: id, name, visibility, context.
The meaning of the remaining attributes is dependent on the trigger
type. We describe each trigger type in following.
7.2.2.1 Trigger Type "attrval"
7.2.2.2 Trigger Type "ctext"
7.2.2.3 Trigger Type "cattrval"
7.2.2.4 Trigger Type "gcattrval"
7.2.2.5 Trigger Type "constant"
7.2.2.6 Trigger Type "ignore"
7.2.2.7 Trigger Type "xmi2assoc"
Prev |
Up |
Next |
Section 7.2.1 "XMI Transformation File Format" | Contents | Section 7.2.2.1 "Trigger Type "attrval"" |