Contents > 7 SDMetrics Metamodel and XMI Transformation Files > 7.2 XMI Transformation Files > 7.2.2 XMI Transformations and Triggers > Trigger Type "gcattrval" Trigger Type "gcattrval"

This trigger retrieves the value from an XMI attribute of a child of a child ("grand child") in the XMI tree.
In our example, the owner of the operation is specified in the child element Foundation.Core.Feature.owner. This child element has another child element of its own, whose attribute "xmi.idref" holds the reference to the operation owner. We retrieve its value with the trigger
<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 "Trigger Type "attrval"", an XMI1.2 exporter can also serialize swimlanes as follows:

<UML:Partition' name='mySwimlane''xmi12'>
  <UML:ModelElement xmi.idref='xmi35'/>
  <UML:ModelElement xmi.idref='xmi61'/>
  <UML:ModelElement xmi.idref='xmi115'/>
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 = 'id127' name = 'full'>
    <UML:CallAction = 'id128' name = 'anon' isAsynchronous = 'false'>
    ... (more entry actions)
    <UML:CallAction = 'id129' name = 'anon' isAsynchronous = 'false'>
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" 
  <trigger name="entryaction" type="gcattrval" src="UML:State.entry" 
        attr="xmi.idref" />
  <trigger name="exitaction" type="gcattrval" src="UML:State.exit" 
        attr="xmi.idref" />
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.