It is possible to define attributes whose value is computed automatically. This definition is part of the object type definition: i.e., for each attribute, the object type specifies name, type and also if and how it is automatically computed.
The computation of an attribute value can be based on the value of all the other attributes of the same object, plus the values of all attributes of referenced objects– directly or indirectly – by the main object.
Here is a simple example: there is an object type ‘person’ that has two attributes ‘firstName’, ‘lastName’. It is possible to define a third attribute ‘completeName’ that will be computed concatenating the values of ‘firstName’ and ‘lastName’ (eventually putting a space in between or other such things).
Computed attributes ARE stored in the database, so that their value can be retrieved or used for searches without extra computations. The computation is performed only when the object (or one of its referenced objects) is modified.
The algorithm to compute the attributes does the following:
1.The object being created or modified is converted into an in-memory XML representation, which includes all of the attributes that already have a value and all of the referenced objects (directly and indirectly).
2.An XSL transformation is applied to this XML.
3.The XML resulting from the transformation is converted back into a temporary object.
4.All the attributes that are marked as ‘automatically computed’ and that are present in the temporary object are copied from it.
The XSL transformation is defined as part of the schema.
Note: The auto-compute doesn't work for the custom attributes, added in <objectname>Extra section. Instead to use an attribute, add it as an element.
See also
Defining auto-computed attributes