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: Each trigger in our transformation describes how to retrieve the information for one SDMetrics metamodel attribute. Each trigger has two required attributes: 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"