For example, let's consider the following UML diagram:
The model has to be valid only if for all of the instances of Block1
, the instance of Block1::unit_of_press
is the same instance of the tagged value unit
of the actual type of Block1::press
Is it possible to express such a constraint in OCL?
Yes, it is possible to access the tagged values of an applied stereotype. See Finding All Elements with a Given Tag as a starting point. From there you can assert what must be true about the tagged value.
In case that web page becomes unavailable, an example is:
(Thanks to Rafael Chaves, Vladimir Orany, and Bjoern Sundin.)