Java Reference
In-Depth Information
with, this topic. This chapter covers the extensions to OCL added in the QVT
spec.
OML is an imperative language that most programmers will find familiar. The
language is used to define unidirectional transformations, although a second trans-
formation can always be written to provide bidirectionality. It can provide imple-
mentations of mappings for the Core or Relations languages when declarative
approaches prove difficult, which is known as a hybrid approach. Transforma-
tions defined exclusively using OML are known as operational mappings.
As you will see in the language description that follows and throughout the
examples in this topic, you can write equivalent QVT scripts in many ways. The
decisions made by the transformation author to use particular techniques and
constructs will be determined by experience, style preference, reusability, and
maintainability factors. As the language and tooling support matures, features
for navigation, refactoring, and optimization of QVT scripts are expected to
improve the experience of working with QVT from its current state.
13.1 Transformation Declaration
A QVT transformation is defined in a file that includes a transformation signa-
ture and main mapping to serve as an entry point. One or more modeltype dec-
larations can also be included to explicitly define the metamodels used in the
transformation. Following is a transformation declaration with modeltype and
main mapping elements:
modeltype UML uses
simpleuml('http://www.eclipse.org/examples/1.0.0/simpleuml');
modeltype RDB uses rdb('http://www.eclipse.org/examples/1.0.0/rdb');
transformation uml2rdb( in uml:UML, out rdb:RDB) {
-- The main entry point of the transformation
main () {
-- Standard model element access and mapping invocation
uml.objects()[Class]-> map class2table();
}
}
As you can see, a transformation definition is much like a class declaration,
with import statements, a signature, and a main() mapping entry point. The
analogy between operational QVT and object-oriented languages is accurate:
Transformations are instantiated and have properties and (mapping) operations.
Note that the mappings of the transformation are enclosed within curly braces
following the transformation signature. This is not required if the file has only
 
Search WWH ::




Custom Search