Prev - Next - Down | SDMetrics - the UML design measurement tool |
It is possible to make the use of an XMI transformation conditional. You may specify a condition for the attributes of the XMI element that must be fulfilled for a XMI transformation to become effective. With this feature, you can filter certain XMI elements, or you can conditionally map one XMI element onto different metamodel element types, depending on the values of its attributes.
For example, the MagicDraw™ UML modeling tool uses a proprietary XMI extension to encode diagram information as follows:
<mdElement elementClass = 'DiagramData' xmi.id = 'ID2546'> <parentID xmi.idref = 'ID0002' /> <type>Class Diagram</type> <mdElement elementClass = 'DiagramView' xmi.id = 'ID2547'> <elementID xmi.idref = 'ID2546' /> <zoomFactor xmi.value = '1.0' /> <mdOwnedViews> <mdElement elementClass = 'ClassView' xmi.id = 'ID2548'> <elementID xmi.idref = 'ID00dd' /> <geometry>165, 16, 358, 60</geometry> </mdElement> <mdElement elementClass = 'ClassView' xmi.id = 'ID2549'> <elementID xmi.idref = 'ID15f2' /> <geometry>40, 170, 600, 111</geometry> </mdElement> ...The XML element mdElement represents both diagrams and diagram elements, indicated by the value of attribute elementClass. The value "DiagramData" denotes a diagram (and we can then extract additional information on diagram type and owner). A value other than "DiagramData" denotes a diagram element (which contains a cross-reference to the UML model element it represents). To define diagram-specific metrics, we must be able distinguish diagrams from diagram elements:
<xmitransformation modelelement="diagram" xmipattern="mdElement" condition="elementClass='DiagramData'" recurse="true"> <trigger name="style" type="ctext" src="type" /> <trigger name="context" type="cattrval" src="parentID" attr="xmi.idref" /> </xmitransformation> <xmitransformation modelelement="diagramelement" xmipattern="mdElement" condition="elementClass!='DiagramData'"> <trigger name="element" type="cattrval" src="elementID" attr="xmi.idref" /> </xmitransformation>The first xmitransformation for model element "diagram" specifies a condition that the "mdElement" XML element must have an attribute elementClass of value "DiagramData". The second xmitransformation for model element "diagramelement" picks up all mdElement instances with an elementClass different from "DiagramData". As a result, "mdElement" DiagramData elements are stored as "diagram" metamodel elements, all others are stored as instances of "diagramelement".
SDMetrics uses the following strategy when searching a suitable XMI transformation for an XML element in the XMI source file:
Prev | Up | Next |
Section 7.2.3.5 "Optional XMI ID" | Contents | Section 8 "Defining Custom Design Metrics and Rules" |