Transformations can be imported and extended by others as shown in the following example.
transformation common(uml:SimpleUML, rdbms:SimpleRDBMS)
{
top relation ClassToPrimarykey
{
theName: String;
checkonly domain uml c:UmlClass {
name = theName
};
enforce domain rdbms k:RdbmsKey {
name = theName+ '_PrimaryKey'
};
}
}import common.qvt;
transformation umlToRdbmsExtended(uml:SimpleUML, rdbms:SimpleRDBMS)
extends umlToRdbms
{
top relation OverridingClass2Table overrides Class2Table
{
/* Relation variables and uml domain same as before */
enforce domain rdbms t:Table {
/* other features same as before */
primaryKey = pk:PrimaryKey {
constitutingColumnc=cl
}
};
/* when clause same as before */
where {
/* Other where expressions same as before */
common::ClassToPrimaryKey(c, pk);
}
}
top relation AssociationToForeignKey
{
/* Content omitted here */
}
}The umlToRdbmsExtended transformation extends the umlTodbms transformation in the last section. Extension complements the relations defined in the extending transformation (i.e. umlToRdbmsExtended) with those of the extended one (i.e. umlToRdbms). Moreover the relation OverridingClass2Table overrides the Class2Table relation from the extended transformation. However the QVT standard does not state whether overriding can change the level of a relation.
Transformation extension and overriding is not yet implemented in medini QVT.
The umlToRdbmsExtended transformation also imports the common transformation defined in
the common.qvt file. Unfortunately the QVT
standard does not exactly specify the semantics of "import" in the
Relations language. In medini QVT, import simply enables relations of
the importing transformation to invoke imported relations. In our
example, the import of "common" enables the invocation of its
ClassToPrimaryKey relation in the where-clause of Class2Table. We
mentioned above that invoking top relations in where-clauses is
forbidden. In the context of import this is not redundant because an
imported relation is considered non top-level and must therefore be
explicitly invoked in a where-clause to make it hold.