The Use of Ocl Expressions in UML Models


This section describes the various manners in which OCL expressions can be used in UML models.
 

Introduction

In principle, everywhere in the UML specification where the term expression is used, an OCL expression can be used. In UML 1.4 OCL expressions could be used e.g. for invariants, preconditions and postconditons, but other placements are possible too. The meaning of the value, which results from the evaluation of the OCL expression, depends on its placement within the UML model.

In this specification the structure of an expression, and its evaluation are separated from the usage of the expression. Chapter 8 ("Abstract Syntax") defines the structure of an expression, and appendix A ("Semantics") defines the evaluation. In chapter 9 ("Concrete Syntax") it was allready noted that the contents of the name space environment of an OCL expression are fully determined by the placement of the OCL expression in the model. In that chapter an inherited attribute env was introduced for every production rule in the attribute grammar to represent this name space environment.

This section specifies a number of predefined places where OCL expressions can be used, their associated meaning, and the contents of the name space environment. The modeler has to define her/his own meaning, if OCL is used at a place in the UML model which is not defined in this section.

For every occurence of an OCL expression three things need to be separated: the placement, the contextual classifier, and the self instance of an OCL expression.
 


In thenext section a number of placements are stated explicitly. For each the contextual classifier is defined, and well-formedness rules are given, that exactly define the place where the OCL expression is attached to the UML model.

UML 2.0 Alignment

The definition of the contextualClassifier and ExpressionInOcl depends to a large extend on the UML 2.0 definition.

Therefore this section will need to be finished after the UML 2.0 definition has been frozen. Therefore not all rules in this section are completely finished, they need to be re-done anyway.