Page 1 of 1

OCL Unknown Type

PostPosted: Tue Nov 24, 2020 10:24 pm
Hello! I am hoping you can help.

I am using Cameo Systems Modeler 19.0 SP3.
I am trying to use OCL to validate that a tag value of a block is not set to a particular enumeration literal, but I keep getting and Unknown type error:


The example model has a profile that defines a stereotype named “Core”.
The Core stereotype redefines an inherited property named “eD” having multiplicity 1 and a type “EXDE”.
Core has a <<validationRule>> constraint named “Core Constraint” applied which specifies:
Code: Select all
Context Core inv Core Constraint
self.eD <> EXDE::I

EXDE is a SysML enumeration ( <<valueType>>) with enumeration literals “I” and “E”.
The model has a BDD with a block named “My Core” having the <<Core>> stereotype applied.
When I validate the BDD I get the error:

Expression has errors:Semantic error at [0:11]: Unknown type ([EXDE,I])

I’m not sure why my enumeration is not understood as a valid Type in OCL, but works fine as a Type in the model.
What would be the OCL to ensure that a Core instance does not have its eD tag set to a value of “I”?

Here are some images from the example:
My Profile.png



Re: OCL Unknown Type

PostPosted: Thu Dec 10, 2020 8:33 pm
I solved my own problem and wanted to post the reply here so others could learn.
I had to explicitly use the fully qualified path to the enumeration literal (that is My_Profile::Data_Types::EXDE::I), and the OCL syntax needed some slight adjustment. Use of the <> operator did not work.

The OCL that worked was:

Code: Select all
Context Core inv Core Constraint
not (self.eD = My_Profile::Data_Types::EXDE::I)