As mentioned above, object templates of a target domain are used to create target model elements. In order not to create duplicates (e.g. during retransformation), an identifier is needed for locating existing model elements. MOF2.0 allows metamodels to denote a structural feature as the identifier of its class. However, from the perspective of a transformation, such a single feature might sometimes not be sufficient or too restrictive. QVT-Relations defines a key concept which can be used to identify a model element. Keys are especially useful if the source and target models were manually modelled and a transformation should not create new target elements but rather map existing target elements identified by appropriate keys. The following code excerpt shows how to indicate that a table is identified by both its name and schema.
transformation umlToRdbms(uml:SimpleUML, rdbms:SimpleRDBMS) { key Table {schema, name}; /* The rest is same as before. Note that the key properties must be assigned in an object template of type Table in order to be applied. */ }
![]() |
Note |
---|---|
The medini QVT engine does not support the "check-before-enforce" semantics described in the QVT standard. In practice, the key concept in combination with using trace information is enough to identify elements before creating them. |