Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Mapping of classes N to 1
Mapping of classes N to 1 [message #1704230] Sun, 09 August 2015 11:01 Go to next message
Abhishek Kappattanavar is currently offline Abhishek KappattanavarFriend
Messages: 4
Registered: August 2015
Junior Member


I am still new to QVTo and learning.

I am trying to transform a model SRC to DST.


Description of the mapping:
The attributes from SRC:Block are being mapped to the DST:Blocks, DST:Diagram and DST:Props

While trying to map SRC class 'Block' to DST classes Blocks I have tried to constructors and intermediate classes (I have attached the ecore diagrams). However, I am getting errors while doing so. Kindly help.

The code I tried:

-- Declaration with a condition: the instance may differ from the metamodel,
-- but should have exactly one Project object. Location specific reference.
modeltype SRC uses "com.example.src" where
{ self.objectsOfType(Model)->size() = 1 };

-- Strict declaration, using a package namespace URI
modeltype DST "strict" uses "com.example.dst";

transformation SRCTransformation(in Source: SRC, out Target: DST);

main() {
Source.rootObjects()[Model] -> map ModelToSciMod();

constructor Props::Props (id:String,val: String) { Id:=id; Value:=val; }

mapping Model::ModelToSciMod(): SciMod {
Name := self.Name;
Version := "4.4";

-- objects:=self.newEReference ->new(x) Props(, P()) ;

var s := self.newEReference ->map ObjToSys();


mapping Systems::ObjToSys(): Objects {
blocks:=self.blocks -> map BlkToBlk();
links:=self.links -> map LnToLn();


--constructor Props::Props (id:String,val: String) { Id:=id; Value:=val; }
constructor Diagram::Diagram (d:Props) { P:=d }
constructor Graphs::Graphs (att:Sequence(Props)) { }

mapping Block:: BlkToBlk(): Blocks {
var type:= self.BlockType;
var sid:= self.SID;
var ports:=self.Ports;

var prop1:= new Props("BlockType", type);
var prop2:= new Props("SID", sid);
var prop3:= new Props("Ports", ports);

var di := new Diagram(prop1) ;

dia:=intermediateDia -> map BlkToDia() ; -- ERROR showing here


intermediate class IntermediateBlk2 {
vars: OrderedSet(Block);

intermediate class IntermediateDia {
vars: OrderedSet(Block);

intermediate property IntermediateBlk2::intermediateDia :IntermediateDia ;

intermediate property IntermediateDia::intermediateP :Block ;

mapping IntermediateBlk2:: BlkToDia(): Diagram {
mapping Line:: LnToLn(): Links {


Kindly help.

Also, kindly let me know if there are any tutorials/reference documents explaining the keywords.

Thank you,
Re: Mapping of classes N to 1 [message #1704280 is a reply to message #1704230] Mon, 10 August 2015 06:58 Go to previous messageGo to next message
Rolf Theunissen is currently offline Rolf TheunissenFriend
Messages: 257
Registered: April 2012
Senior Member
Hello Abhishek,

For documentation about QVTo check the WIKI:

Especially the EclipseCon 2009 presentation.

If you want a complete overview off all keywords, check the QVTo specification.

If you want help with your error, please list the error as well. Also providing minimal examples of your problem in your question instead of listing everything will help in getting answers.

As a start, adding intermediate properties to intermediate classes is strange (and maybe not well supported by the implementation). Add those attributes directly to the intermediate class.
Re: Mapping of classes N to 1 [message #1705959 is a reply to message #1704280] Thu, 20 August 2015 12:37 Go to previous message
Abhishek Kappattanavar is currently offline Abhishek KappattanavarFriend
Messages: 4
Registered: August 2015
Junior Member
Hi Rolf,

Thank you for your inputs. I abandoned the usage of intermediate classes and I am trying other ways. And I am sorry, I shall try to keep it short.
Previous Topic:Javadocs
Next Topic:QVTo Abstract Syntax Tree Fetch
Goto Forum:

Current Time: Mon May 23 22:18:28 GMT 2022

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

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

Back to the top