[QVTo] How to extend a model [message #697089] |
Fri, 15 July 2011 13:52 |
--alex-- Messages: 26 Registered: October 2009 |
Junior Member |
|
|
Hi all,
I'm new to m2m transformations,
Is there a way to transform a model A to a model B (conforming to the same metamodel, UML in my case) in which, for example, the model elements of B are the same model elements of A except for the addition of some properties (like a stereotype, or and extended name)?
Is there a way to "clone" elements and then add or change some of their properties?
Since I didn't find a way to do this, I just tried to change the name of the UML::Model element with the following in-place transformation:
modeltype UML uses "http://www.eclipse.org/uml2/2.0.0/UML";
transformation NewTransformation(inout source:UML);
main() {
var m := source.rootObjects()![Model];
m.map toNewModel();
}
mapping inout Model::toNewModel(): Model{
name := self.name + 'newName';
}
Unfortunately the output is the same model with the actual UML::Model element (which I meant to change) with the name correctly set to the new one BUT with an additional UML::Model element which is void.
I managed to change the name of the model without introducing a new UML::Model by using a helper function, but this does not generate a .trace file which I need.
Anyway this is not what I want, I did it just for practice.
What I really need is a transformation with a input UML model and an output UML model, in which the output file is the same of the input except for additional properties.
Is there a way to achieve this?
|
|
|
Re: [QVTo] How to extend a model [message #697095 is a reply to message #697089] |
Fri, 15 July 2011 14:11 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi Alex
The lack of a 'clone' or 'copy' is a significant language omission.
Regards
Ed Willink
On 15/07/2011 14:52, --alex-- wrote:
> Hi all,
> I'm new to m2m transformations,
> Is there a way to transform a model A to a model B (conforming to the
> same metamodel, UML in my case) in which, for example, the model
> elements of B are the same model elements of A except for the addition
> of some properties (like a stereotype, or and extended name)?
>
> Is there a way to "clone" elements and then add or change some of
> their properties?
>
> Since I didn't find a way to do this, I just tried to change the name
> of the UML::Model element with the following in-place transformation:
>
>
>
> modeltype UML uses "http://www.eclipse.org/uml2/2.0.0/UML";
>
> transformation NewTransformation(inout source:UML);
> main() {
> var m := source.rootObjects()![Model];
> m.map toNewModel();
> }
>
> mapping inout Model::toNewModel(): Model{
> name := self.name + 'newName';
> }
>
>
> Unfortunately the output is the same model with the actual UML::Model
> element (which I meant to change) with the name correctly set to the
> new one BUT with an additional UML::Model element which is void.
>
> I managed to change the name of the model without introducing a new
> UML::Model by using a helper function, but this does not generate a
> .trace file which I need.
>
> Anyway this is not what I want, I did it just for practice. What I
> really need is a transformation with a input UML model and an output
> UML model, in which the output file is the same of the input except
> for additional properties.
> Is there a way to achieve this?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04799 seconds