In QVT Relations, the whole mapping can be expressed by a transformation constituting of relations for the above rules. The following code snippet declares the above transformation without any of the relations. QVT Relations keywords are in bold.
transformation umlToRdbms(uml:SimpleUML, rdbms:SimpleRDBMS)
{
-- This is a single line comment.
/* This is a multi-line comment
This transformation does nothing because
no relations have been declared
*/
}The
umlToRdbms
transformation
has two parameters which
represent the metamodels of the models involved in the transformation.
uml
and
rdbms
are the
identifiers of the models and SimpleUML and SimpleRDBMS are their
metamodels respectively (i.e. the outermost packages). Their order
does not automatically determine the source and target models. The
target is specified at runtime when invoking the transformation and it
is called the
execution direction.
A
transformation may have more than two parameters, but only one can
serve as the target when invoking the transformation. This late
binding of the execution direction enables us to write bidirectional
(or in general: multi-directional) transformations. For example, you
can model an UMLPackage and generate a Schema by executing the QVT
transformation in a certain direction, but you can also generate an
UMLPackage out of a given Schema by using the same transformation but
the opposite execution direction (see the Bidirectionality section for
more details). In this document, we will always use the rdbms
direction and call it "forward transformation" unless otherwise
stated. The metamodels must not be pairwise different. The same
applies to the models being transformed. If the transformation is
within the same model, it is called
in-place
transformation
. The comments show the use of single and
Java-like multi-line comments.
|
Note |
|---|---|
|
The standard does not specify the extension of QVT Script files. As a convention in medini, the .qvt extension is used, only one transformation should be defined per file and the name of the transformation should be the same as that of the file. The file defining the above transformation will therefore be named umlToRdbms.qvt. |
|