Skip to content

Path Expressions

Behavioral knowledge—including constraints, defaults, and calculations—is defined within a specific structure but is applied across the product's component hierarchy at runtime. This application often necessitates referencing elements across various instances and levels of the hierarchy. The COOM language facilitates this by allowing path expressions to reference specific fields or attributes from any part of the hierarchy, using dots (.) to concatenate paths.

In the example, we specify that the color of the carrier should match the color of the whole bike (root.color).

  behavior {
     require root.carrier.color = root.color
  }

Note: The keyword root always refers to the product root.

Path expressions not starting with root are resolved relatively to the current structure being described. For example, to indicate that the color of the bags and the color of the carrier should be equal, you can use relative path expressions.

structure Carrier {
    Color color
    Bag   bag        
}

structure Bag {
    Capacity capacity
    Material material
    Color    color
}

// The behavior has the relative anchor 'Carrier'
behavior Carrier {
    require color = bag.color
}

Here, the behavior is defined for the structure Carrier, where its color need to be equal to the color of its contained bag.

When defining a scope for a behavior, features in the part-of hierarchy sub-tree defined by this type can be referenced straight forward as shown in the above examples. We can point to features outside that sub-tree by an absolute reference using the root keyword. In particular cases, it can be handy to specify static features, that can be referenced easily from everywhere else.