You can parse a single Object Constraint Language (OCL) statement
to ensure that it is syntactically valid. If the OCL resource contains multiple
OCL statements, the
Console view reports that the OCL
statements are syntactically incorrect. However, you can avoid this result
if you parse one OCL statement at a time.
Before you begin
To parse 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 parse 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 parse 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 a target model. This selection determines the available
context elements.
- In the Context Element field, specify a
context element.
- Complete one of the following steps:
- To parse the only OCL statement in the OCL resource, click .
- To parse one of many OCL statements in the OCL resource, right-click
the statement; then click Parse selected.
Results
If the parse is successful, the Console view
reports that the OCL statement is syntactically valid. If the parse fails,
the first encountered syntax error is displayed in the Console view
and additional information is displayed in the Problems view.