Skip to main content



      Home
Home » Modeling » QVT-OML » Create new element in target model
Create new element in target model [message #1847646] Tue, 02 November 2021 19:14 Go to next message
Eclipse UserFriend
Hi all,

Considering we have the following two metamodels.

Metamodel A used as source metamodel:

index.php/fa/41244/0/

and metamodel C as target metamodel:

index.php/fa/41245/0/

As you can see, the target metamodel contains one extra elements "ElementPool" that is not present in the source metamodel. In order to transform Element2Element, I first need to create "ElementPool" and then transform elements and put "Element" as a child of "ElementPool".

I wrote the following transformation:

modeltype A uses metamodelA('http://www.example.org/metamodelA');
modeltype C uses metamodelC('http://www.example.org/metamodelC');


transformation test(in srcModel:A, out trgModel:C);

main() {
srcModel.rootObjects()[A::Map] -> map Map2Map();
}
mapping Map :: Map2Map() : C::Map 
{
var pool : C::ElementPool;
elementpool := pool;
pool.elements := self.element.map toElement();
}

mapping Element:: toElement() : C::Element
{
name:=self.name;
}


But, the issue is that "ElementPool" is still not being created. Is there another syntax to it, or the logic is not right?

Thank you in advance!
Re: Create new element in target model [message #1847650 is a reply to message #1847646] Wed, 03 November 2021 01:49 Go to previous messageGo to next message
Eclipse UserFriend
Hi

It's pretty much the same as Java. If you declare a variable that doesn't make it exist. You need a new expression to create it.

Same in QVTo, you need an object creation, either explicitly via an object expression or implicitly as part of a mapping.

(It would be better if QVTo, like JDT diagnosed the problem by reporting that pool was not adequately initialized.)

Regards

Ed Willink
Re: Create new element in target model [message #1847660 is a reply to message #1847650] Wed, 03 November 2021 03:41 Go to previous messageGo to next message
Eclipse UserFriend
Quote:
(It would be better if QVTo, like JDT diagnosed the problem by reporting that pool was not adequately initialized.)


https://bugs.eclipse.org/bugs/show_bug.cgi?id=577023 raised.

Regards

Ed Willink
Re: Create new element in target model [message #1847661 is a reply to message #1847650] Wed, 03 November 2021 04:05 Go to previous message
Eclipse UserFriend
Ed Willink wrote on Wed, 03 November 2021 01:49
Same in QVTo, you need an object creation, either explicitly via an object expression or implicitly as part of a mapping.
Right. A third option is invoking a constructor, which must be declared first.
Previous Topic:Can we map two abstract classes?
Next Topic:Compiling performance
Goto Forum:
  


Current Time: Fri Nov 07 08:32:09 EST 2025

Powered by FUDForum. Page generated in 0.03290 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top