Initial value expression
An initial value expression is an expression that may be linked to an
Attribute
of a Classifier, or to an AssociationEnd. An OCL expression acting as
the
initial value of an attribute must conform to the defined type of the
attribute.
An OCL expression acting as the initial value of an association end
must
conform to the type of the association end, i.e. the type of the
attached
Classifier when the multiplicity is maximum one, or OrderedSet with
element
type the type of the attached Classifier when the multiplicity is
maximum
more than one.
The OCL expression is evaluated at the creation time of the instance
that owns the attribute for this created instance in the case of an
inital
value for an attribute. In the case of an inital value for an
association
end, the OCL expression is evaluated at the creation time of the
instance
of the Classifier at the other end(s) of the association.
The placement of an attribute initial value in the UML metamodel is
shown in Figure 32. The following well-formedness rule must hold. This
rule also defines the value of the contextual Classifier.
Note The placement of an intial value of an
association
end is dependent upon the UML 2.0 metamodel. So are the well-formedness
rules for this case.
Well-formedness rules
[1] The Expression is the initial value of an attribute (A), and the
Attribute
has an owner (B). The contextual classifier is the owner of the
attribute,
and the type of the OCL expression must conform to the type of the
attribute.
context
ExpressionInOcl
inv:
self.attribute->notEmpty()
-- A
and

self.attribute.owner->size()
= 1 -- B
implies
contextualClassifier = self.attribute.owner
and
self.bodyExpression.type.conformsTo(self.attribute.type)
[2] Inside an initial attribute value the use of @pre is not
allowed.
context
ExpressionInOcl
inv:
-- TBD