Parsing OCL statements

You can parse a single 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.

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
To parse an OCL statement in the Modeling perspective:
  1. In the Model Explorer view, double-click an OCL resource that contains an OCL statement.
  2. At the top of the editor, from the Target Model list, select a target model. This selection determines the available context elements.
  3. In the Context Element field, specify a context element.
  4. Complete one of the following steps:
    • To parse the only OCL statement in the OCL resource, click OCL > Parse.
    • To parse one of many OCL statements in the OCL resource, right-click the statement; then click Parse selected.

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.

Related concepts
OCL resources and statements
Target models for OCL statements
Related tasks
Creating OCL resources
Writing OCL statements
Evaluating OCL statements
Terms of use | Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.