Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Iteratin on 0-n reference
Iteratin on 0-n reference [message #63186] Sat, 29 September 2007 00:42 Go to next message
Eclipse UserFriend
Originally posted by: felouerkhaoui.gmail.com

Hello ,

I want to transform a collection to another type of collection in a atl
file. I'm new to atl scripts and I don't know where to put exactly the
code who will transform entites to datalayer.

Thanks.

transform.atl:

module transform; -- Module Template
create OUT : detailed from IN : itarone;
rule Domaine {
from
a : itarone!Domaine
to
b : detailed!Domaine (
name <- a.name
)
}


My source ecore is represented by the following mk3 content :
package source{

class Domaine {
attribute name[0-1] : ;
reference entites[0-1000] ordered container : Entite;
reference usecases[0-1000] ordered container : UseCase;
reference subDomaines[0-100] ordered container : Domaine;
}

class Entite {
attribute name[0-1] : ;
reference usecases[0-1000] ordered container : UseCase;
}

class UseCase {
attribute name[0-1] : ;
reference entites[0-1000] ordered : Entite;
}
}
My destination ecore :
package destination{

class Domaine {
attribute name[0-1] : ;
reference dataLayer[0-n] container : DataLayer;
}

class DataLayer {
attribute name[0-1] : ;
}
}
Re: [ATL] Iteratin on 0-n reference [message #63232 is a reply to message #63186] Sat, 29 September 2007 18:20 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

Could you please remember to prefix the subject of your ATL-related
posts with [ATL]? (see http://wiki.eclipse.org/M2M)

> I want to transform a collection to another type of collection in a atl
> file. I'm new to atl scripts and I don't know where to put exactly the
> code who will transform entites to datalayer.

You should do this in another rule:

rule Entite2DataLayer {
from
s : itarone!Entite
to
t : detailed!DataLayer (
name <- s.name
)
}

Then, you can add:
dataLayer <- a.entites
in your Domaine rule below:
name <- a.name


Regards,

Frédéric Jouault
Previous Topic:[ATL] Compiling outside eclipse (part II)
Next Topic:strings library
Goto Forum:
  


Current Time: Sun Apr 11 02:21:33 GMT 2021

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

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

Back to the top