Contents > 8 Defining Custom Design Metrics and Rules > 8.1 Definition of Metrics > 8.1.1 Projection > 8.1.1.3 Filter Attribute "target"
8.1.1.3 Filter Attribute "target"
To count only elements of a certain type in a relation or set, you can
specify the optional "target" attribute:
<metric name="NumOps" domain="class">
<description>The number of operations in the class.</description>
<projection relation="context" target="operation" />
</metric>
This only counts elements of type "operation" whose "context" is the
given class, i.e., the number of operations of the class.
If you want to count elements of various types, specify the additional
types separated by a "|". For example, to count the classes,
interfaces, and data types in a package, we write:
<metric name="NumEl" domain="package">
<projection relation="context" target="class|interface|datatype" />
</metric>
Prev |
Up |
Next |
Section 8.1.1.2 "Attribute "relset"" | Contents | Section 8.1.1.4 "Filter Attributes "element" and "eltype"" |