Target models for OCL statements

When you write Object Constraint Language (OCL) statements, the target model determines which features of the context element your OCL statements can access. The target model can be either the user model or the metamodel.

User model

When you specify the target model as the user model, you limit your OCL statements to the user-defined features of the context element. Also, when you specify the target model as the user model, you cannot evaluate OCL statements. You can only parse OCL statements to ensure that they are syntactically valid.

For example, if you specify the target model as the user model, and you select a class or an interface as your context element, your OCL statements are limited to the following attributes and operations:
  • Attributes that the class or interface define
  • Specific OCL-defined operations, such as oclIsType()

Metamodel

When you specify the target model as the metamodel, your OCL statements have access to the metamodel features of the context element, and any features that stereotypes applied to the context element contribute. Also, when the target model is the metamodel, you can parse OCL statements to see if they are syntactically valid, as well as evaluate the output from them.

For example, if you specify the target model as the metamodel, your OCL statements can access to the following features:
  • All the attributes that the metaclass that represents the context element defines
  • Attributes that stereotypes applied to the context element define
  • All the OCL-defined methods
Related concepts
Context elements for OCL statements
Related tasks
Parsing OCL statements
Evaluating OCL statements
Exploring characteristics of UML model elements
Terms of use | Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.