Contents > 7 SDMetrics Metamodel and XMI Transformation Files > 7.2 XMI Transformation Files > 7.2.3 Tips on Writing XMI Transformations > 7.2.3.2 Multiple Triggers per Attribute
7.2.3.2 Multiple Triggers per Attribute
It is possible to specify multiple triggers for one attribute or
relation. For example, in XMI1.1 and XMI1.2, most model element
information can be specified either via XML attributes or via XML
elements. For instance, the name of a class can be specified like
this:
<UML:Class xmi.id="cls1" name="Rectangle" />
or like this:
<UML:Class xmi.id="cls1">
<UML:ModelElement.name>Rectangle</UML:ModelElement.name>
</UML:Class>
Therefore, the XMI transformations for these XMI versions have two
triggers for most attributes, one trigger for each option. In the
above example, the triggers to retrieve the class names are:
<xmitransformation modelelement="class" xmipattern="UML:Class">
<trigger name="name" type="attrval" attr="name" />
<trigger name="name" type="ctext" src="UML:ModelElement.name" />
...
</xmitransformation>
Multiple triggers are also useful to support modeling tools that
deviate in minor ways from the UML standards. For example, some
modeling tools denote the parent/child elements in a UML1.x
generalization by "supertype" and "subtype", instead of the proper
"parent" and "child". In many cases, you can simply add a trigger for
the nonstandard way of representing the attribute, and a single XMI
transformation file is thus capable of handling various XMI
exporters.
Prev |
Up |
Next |
Section 7.2.3.1 "The "linkbackattr" Trigger Attribute" | Contents | Section 7.2.3.3 ""Context" Attribute Defaults" |