Contents > 8 Defining Custom Design Metrics and Rules > 8.1 Definition of Metrics > 8.1.3 Attribute Value
8.1.3 Attribute Value
You can define a metric which returns the value of a SDMetrics
metamodel attribute of an element or a related element. This is useful
if you want attribute values to appear in the output table, and it can
help simplify the definition of other metrics. For example, to show
the "visibility" attribute for elements of type "operation" in the
output tables:
<metric name="visibility" domain="class">
<description>The visibility of the operation.</description>
<attributevalue attr="visibility"/>
</metric>
An attributevalue element has three attributes:
- attr (required) specifies the metamodel attribute to
return.
- element and eltype (both optional) if you want
to access the attribute of a related element, not the model element
itself; we know these attributes from projections, see Section 8.1.1.4 "Filter Attributes "element" and "eltype"".
The below examples demonstrates the "element" attribute. The metric
shows the name of a parameter's type.
<metric name="typename" domain="parameter">
<description>The parameter type name.</description>
<attributevalue element="parametertype" attr="name"/>
</metric>