|Prev - Next - Down||SDMetrics - the UML design measurement tool|
Composite aggregations in XMI 2.x
In XMI 2.x, the elements that play the parts in composite aggregations between metamodel elements are serialized in such a way that their types are not specified explicitly in the XMI file. For example, the type "Class" in the UML2 metamodel has a composite 1:n aggregation to the type "Property". The role name for the parts is "ownedAttribute". A class named "aClass" with two attributes "attr1" and "attr2" is serialized as follows:
<uml:Model xmi:version="2.0" xmi:id="xmi.1" name='aModel' ... <ownedMember xmi:type='uml:Class' xmi:id='xmi.42' name='aClass'> <ownedAttribute xmi:id='xmi.43' name='attr1' type='xmi.2001'/> <ownedAttribute xmi:id='xmi.44' name='attr2' type='xmi.1138'/> </ownedMember> ... </UML:Model>The name of the XML elements defining the attributes "attr1" and "attr2" is the role name "ownedAttribute" of the aggregation in the metamodel. We need to provide SDMetrics with the information that "ownedAttribute" associates classes with elements of type "Property". This can be done with the "xmi2assoc" trigger as follows:
<xmitransformation modelelement="class" xmipattern="uml:Class"> <trigger name="properties" type="xmi2assoc" attr="ownedAttribute" src="uml:Property"/> ... </xmitransformation> <xmitransformation modelelement="property" xmipattern="uml:Property"> ... </xmitransformation>The attribute "attr" of the trigger specifies the role name of the aggregation that is also the name of the XML element defining the part. The attribute "src" specifies the XMI pattern of the XMI transformation that should be used to process the part definition. The attribute "name" specifies the name of the (multi-valued) SDMetrics metamodel cross-reference attribute that stores the reference(s) to the part(s).
If a part is a subtype of the associated class, the XMI exporter must indicate the type of the part with the "xmi:type" attribute. If such a type is specified, SDMetrics will of course use the XMI transformations defined for that type.
The "src" attribute is optional if the type of the parts in the UML2 metamodel is abstract. In that case, the concrete type of the part must always be indicated in the XMI file with the xmi:type attribute. In the example above, the UML2 metamodel class "Model" has a composite aggregation with the abstract class "PackageableElement"; the role name of the parts is "ownedMember". The following XMI transformation collects all members of the model:
<xmitransformation modelelement="model" xmipattern="uml:Model"> <trigger name="members" type="xmi2assoc" attr="ownedMember" /> </xmitransformation>Associations in XMI 2.x
The "xmi2assoc" trigger can also be used to capture plain associations that are not aggregations. For example, the UML2 metamodel class "InstanceSpecification" has an association with class "Classifier", the role name is "classifier". To serialize an instance specification with several classifiers, an XMI exporter has two options:
<!-- first option: --> <ownedMember xmi:type='uml:InstanceSpecification' xmi:id='xmi.42' name='myInstance'> <classifier xmi:idref='xmi.43'/> <classifier xmi:idref='xmi.44'/> </ownedMember> <!-- second option: --> <ownedMember xmi:type='uml:InstanceSpecification' xmi:id='xmi.42' name='myInstance' classifier='xmi.43 xmi.44'/>The following XMI transformation will handle both options with one trigger:
<xmitransformation modelelement="instancespec" xmipattern="uml:InstanceSpecification"> <trigger name="classifiers" type="xmi2assoc" attr="classifier" /> </xmitransformation>Here we assume that the SDMetrics metamodel type "instancespec" has a multi-valued cross-reference attribute "classifiers" that stores the references to the classifiers of the instance specification.
|Section 184.108.40.206 "Trigger Type "ignore""||Contents||Section 7.2.3 "Tips on Writing XMI Transformations"|