Writing OCL statements

You can write an Object Constraint Language (OCL) statement to query the characteristics of UML model elements.

Before you begin

To write an OCL statement, you must have a model or profile open, and have an OCL resource in your workspace.

About this task

To write an OCL statement in the Modeling perspective:

Procedure

  1. In the Project Explorer view, double-click an OCL resource.
  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. In the editor, type your OCL statement.
    • When you type a period ("."), an arrow ("->"), a caret ("^"), or a double colon ("::"), the content assist window displays a list of entries from which you can select to continue your statement.
    • The self keyword substitutes for the context element in OCL statements.
    • For information about OCL syntax, refer to the UML 2.0 OCL Specification document.
  5. To save the OCL resource, click File > Save.

Feedback