Contents > 8 Defining Custom Design Metrics and Rules > 8.1 Definition of Metrics > 8.1.1 Projection > 18.104.22.168 Attribute "relation"
22.214.171.124 Attribute "relation"
In its simplest form, the projection gives you, for a certain element,
a count of all elements having a certain relationship with that
element. The attribute "relation" specifies the relationship.
Here's an example of a simple projection:
<metric name="NumElements" domain="class">
<description>The number of elements in the class.</description>
<projection relation="context" />
The metric NumElements is defined for elements of type "class". It
counts, for a given class, all elements which have a reference
attribute "context" that points to that class. Attribute "context"
specifies the owner of a model element. So this metric counts all
model elements of which the class is the owner, that is, the number of
elements in the class. Those elements can be of any type, e.g.,
operations, attributes, or other classes (inner classes).