You can evaluate a single Object Constraint Language (OCL) statement
to query the characteristics of your metamodel. For example, you can evaluate
an OCL statement that returns a simple type, such as a Boolean value, or you
can evaluate an OCL statement that returns a list of metamodel objects. If
the OCL resource contains multiple OCL statements, the
Console view
reports that the OCL statements are syntactically incorrect. However, if the
OCL resource contains multiple OCL statements, you can evaluate a single selected
OCL statement.
Before you begin
To evaluate an OCL statement, you must set the target model to Meta
Model. Also, to evaluate an OCL statement, you must have a model
or profile open, and have an OCL resource in your workspace.
If any
of the following conditions are true when you evaluate an OCL statement, the
Console view
reports that the OCL statement is syntactically incorrect:
- An OCL statement refers to an element by its name or fully qualified name,
and the element name or fully qualified name contains spaces
- An OCL statement uses fields whose names are OCL keywords
- An OCL statement uses enumerations that are defined by a profile
About this task
To evaluate an OCL statement in the
Modeling perspective:
Procedure
- In the Project Explorer view, double-click
an OCL resource that contains an OCL statement.
- At the top of the editor, from the Target Model list,
select Meta Model.
- In the Context Element field, specify a
context element.
- Complete one of the following steps:
- If the OCL resource contains only one OCL statement, click .
- If the OCL resource contains several OCL statements, right-click one
statement; then click Evaluate selected.
Results
If the evaluation is successful, the results from the OCL statement
are displayed in the Console view. If the evaluation
fails, the first encountered syntax error is displayed in the Console view,
and additional information is displayed in the Problems view.