|Prev - Next - Down||SDMetrics - the UML design measurement tool|
<trigger name="context" type="gcattrval" src="Foundation.Core.Feature.owner" attr="xmi.idref"/>The "src" attribute of the trigger specifies the child element name, the "attr" attribute of the trigger specifies the attribute of the grandchild element we want to access. Note that we do not specify the element name of the grandchild. For single-valued attributes such as "context", the trigger always accesses the first child of the specified child element, regardless of its name.
We can also use the trigger for multi-valued attributes. Revisiting the example of UML1.x activity partitions from Section 18.104.22.168 "Trigger Type "attrval"", an XMI1.2 exporter can also serialize swimlanes as follows:
<UML:Partition' name='mySwimlane' xmi.id='xmi12'> <UML:Partition.contents> <UML:ModelElement xmi.idref='xmi35'/> <UML:ModelElement xmi.idref='xmi61'/> <UML:ModelElement xmi.idref='xmi115'/> </UML:Partition.contents> </UML:Partition>The trigger
<trigger name="contents" type="gcattrval" src="UML:Partition.contents" attr="xmi.idref"/>will visit each child XML element of the UML:Partition.contents element, and store the values of their "xmi.idref" attributes in the multi-valued attribute "contents" of SDMetrics' "partition" metamodel element.
The "gcattrval" trigger has one more function that is not related to extracting values from XML attributes. If a model element is defined as child element of the XML element specified by the trigger's "src" attribute, the trigger will store a cross-reference to that model element with the attribute for which the trigger is defined. Consider the following example of entry and exit actions of a state in UML1.4:
<UML:SimpleState xmi.id = 'id127' name = 'full'> <UML:State.entry> <UML:CallAction xmi.id = 'id128' name = 'anon' isAsynchronous = 'false'> ... </UML:CallAction> ... (more entry actions) </UML:State.entry> <UML:State.exit> <UML:CallAction xmi.id = 'id129' name = 'anon' isAsynchronous = 'false'> ... </UML:CallAction> </UML:State.entry> ... </UML:SimpleState>The entry and exit actions are defined as child elements of the UML:State.entry and UML:State.exit elements. The "state" element of SDMetrics' metamodel for UML1.x has two multi-valued cross-reference attributes "entryaction" and "exitaction". For these, we define the following triggers:
<xmitransformation modelelement="state" xmipattern="UML:SimpleState" recurse="true"> <trigger name="entryaction" type="gcattrval" src="UML:State.entry" attr="xmi.idref" /> <trigger name="exitaction" type="gcattrval" src="UML:State.exit" attr="xmi.idref" /> ... </xmitransformation>With these triggers, SDMetrics will store cross-references to the model elements defined as children of the UML:State.entry and UML:State.exit XML elements in the "entryaction" and "exitaction" attributes of SDMetrics model element "state", respectively. Note that the values of the "attr" attributes of the triggers play no role in this.
|Section 22.214.171.124 "Trigger Type "cattrval""||Contents||Section 126.96.36.199 "Trigger Type "constant""|