A transformation using the source model also as target model often requires to use variables bound in source domains also in target domains. This can be realized by using object templates with the same variable name. This is demonstrated in the following example (note that this is not an in-place transformation in the sense as it can be specified in the QVT launch configuration dialog, see chapter QVT launch configuration ):
transformation umlToUml(source:SimpleUML, target:SimpleUML) { top relation EnsureClassHasAnAttribute { enforce domain source c:UmlClass {}; enforce domain target c:UmlClass { umlAttribute = a:UmlAttribute { umlOwner = c } }; when { c.umlAttribute->size()=0; } } }
The above in-place transformation ensures that every UML class has at least one attribute. The UMLClass instance is bound to a variable c in the source domain which is reused in the target domain.
It is also possible to use object templates with the same name within one domain. It is always an error to specify object templates with the same name but with different types.