Writing OCL statements

You can write an OCL statement to query the characteristics of UML model elements.

To write an OCL statement, you must have a model or profile open, and have an OCL resource in your workspace.
To write an OCL statement in the Modeling perspective:
  1. In the Model 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. Information about proper OCL syntax is available on the UML Resource Center, in the UML 2.0 OCL Specification document, in the "Standard UML documentation" section.
    Tip: When you write OCL statements, the self keyword substitutes the context element.
  5. To save the OCL resource, click File > Save.
Related tasks
Creating OCL resources
Parsing OCL statements
Evaluating OCL statements
Related reference
UML 2.0 OCL Specification on the UML Resource Center
Terms of use | Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.