A context can be defined on a schema element to restrict its domain of validity to certain instances or property values. This means mapping cells defined on contexts are not generally in effect, but only on certain conditions, in a certain context.
As an example, you can use contexts to express a relation like this:
The type Product in the source schema is the same as the type Shirt in the target schema if its property type has the value 'shirt'.
This example can be realised, if a condition context is created
for the type Product, with the condition
type = 'shirt'
, and a Retype
relation is created between the defined Product context and the
Shirt type.
Contexts are defined using expressions and filters in Common Query language (CQL).
Types of contexts that can be defined on the source schema.
A condition context defines a condition on a type or property, that is evaluated on the instance or property value respectively. Only if the condition is fulfilled, an associated mapping takes effect.
An index context can only be defined on properties that may occur multiple times. It specifies an index, which references a certain property value, e.g. the index zero referencing the first property value, the index one the second, etc.
A mapping associated to an index context only takes effect if an instance has a property value with the specified index.
Types of contexts that can be defined on the target schema.
An instance context can similar to an index context only be defined on properties that may occur multiple times. It represents an additional property instance that a mapping can use as a target, e.g. if the same target property is to be populated from the source in different ways.
Type condition context example
Simple example project demonstrating the use of filters on source
types.
The source type item is mapped to two
different target types shirt and hat, according to the
value of the property type.
Property condition context example
Simple example project that demonstrates how a condition on a source property can be used to map a source property to different target properties depending on its value.
Small example project demonstrating the use of an index context for
source properties.
In the source type placeNames the
information on the name language is given only implicitly through
the name order. The first name is in German, the second in English,
the third in Italian.In the target type explicitNames there
are explicit name properties for each language defined.