Contents > 8 Defining Custom Design Metrics and Rules > 8.2 Definition of Sets > 8.2.1 Projection > 8.2.1.1 Attribute "recurse"

8.2.1.1 Attribute "recurse"

The recurse attribute known from metrics projections is also available for sets. By setting recurse="true", SDMetrics recursively calculates and takes the union of sets for same type elements in the relation. For example, we can easily change the definition of the set of children classes from above to yield the element set of descendents classes:

<set name="Descendents" domain="class"> 
  <description>The set of descendents of a class.</description>
  <projection relation="genparent" target="generalization"
              element="genchild" eltype="class" recurse="true"/>
</set>
For each child class, the set "Descendents" is evaluated, and the union of all these sets is taken. The child classes themselves also are included in the set. This effectively produces the set of descendents for a class.