Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Splitting ASMModel
[ATL] Splitting ASMModel [message #60167] Sun, 02 September 2007 14:34 Go to next message
Eclipse UserFriend
Originally posted by:


my transformation gives me the following output model:
************************************************************ **********
<root id=3D1></root>
<root id=3D2></root>
<root id=3D3></root>

I now want to split the model programmatically in 3 outputmodels, each =

containing one of the root-elements:
************************************************************ **********
<root id=3D1></root>
<root id=3D2></root>
<root id=3D3></root>

Having the outputModel, I create a new ASMModel for each root-Element, b=
ut =

how do I get the rootElement in the ASMModel?
There is only a method addSubModel() and no methods to add an element to=

the model.
Or do I need to work with EMF to do the splitting?
************************************************************ **********
ASMModel outModel;
ASMModel metaModel;
Set<ASMModelElement> rootElements =3D (Set<ASMModelElement>) =

Iterator<ASMModelElement> iterator =3D rootElements.iterator();
while(iterator.hasNext()) {
ASMModelElement rootElement =3D;
ASMModel rootModel =3D handler.newModel(rootElement.getName(), metaMode=

//adding element to model
//saving model


Thanks Rainer
Re: [ATL] Splitting ASMModel [message #60191 is a reply to message #60167] Sun, 02 September 2007 19:47 Go to previous message
Eclipse UserFriend
Originally posted by:

Well, I tried it with EMF and it works now.
For anyone who is interested:

The code is used within a eclipse plugin.
The plugin project needs to import the generated EMF model code of the =


//********************************************************** *****
roots.model is the saved ASMModel:
<Root id=3D1></Root>
<Root id=3D2></Root>
<Root id=3D3></Root>
URI fileURI =3D URI.createFileURI(new File("roots.model").getAbsolutePat=
Resource source =3D resourceSet.getResource(fileURI, true);

//Get all root-elements
TreeIterator elements =3D source.getAllContents();
//Root is the EMF generated class representing the metamodel element
ArrayList<Root> rootElements =3D new ArrayList<Root>();
while(packages.hasNext()) {
EObject o =3D (EObject);
if(o instanceof Root) {

//Saving each root-Element as model
for(int i =3D 0; i < packs.size(); i++) { =


Root root =3D roots.get(i);
//<Root id=3D1></Root>
//Get the URI of the model file.
URI newFileURI =3D URI.createFileURI(root.getId() + ".model");

//Create a resource for this file.
Resource resource =3D resourceSet.createResource(newFileURI);

// Add the book and writer objects to the contents.
catch (IOException e) {}

//********************************************************** *****

Previous Topic:[ATL] how to apply stereotypes???
Next Topic:[ATL] atlcommandline
Goto Forum:

Current Time: Mon Oct 03 08:42:25 GMT 2022

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

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

Back to the top