Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [xpand] how to get input model from xmi
[xpand] how to get input model from xmi [message #529036] Thu, 22 April 2010 17:06 Go to next message
Yu Sun is currently offline Yu SunFriend
Messages: 58
Registered: July 2009
Member
Hi everyone,

I am writing a Java code to trigger the xpand template. I am using XpandFacade.evaluate() method. The first parameter is the template file, and the second one is the input model (root, correct?). Therefore, I am just wondering how can I turn a selected ecore file into a model object here.

Thanks a lot.

Yu
Re: [xpand] how to get input model from xmi [message #529058 is a reply to message #529036] Thu, 22 April 2010 19:03 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
hello,

yes the second parameter is the model.
loading emf based models is a thing that is done by the emf persistence api. getting the currect selection is a part of jface.

something like

IFile iFile = (IFile) structuredselection.getFirstElement();
URI uri = URI.createPlatformResourceURI(iFile.getPath().toString(), true);
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource = resourceSet.getResource(uri, true);
MyModelRootClass model = (MyModelRootClass ) resource.getContents().get(0);


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: [xpand] how to get input model from xmi [message #529070 is a reply to message #529058] Thu, 22 April 2010 19:58 Go to previous message
Yu Sun is currently offline Yu SunFriend
Messages: 58
Registered: July 2009
Member
Thanks Christian. The code works perfect!
Previous Topic:[Acceleo] Multi meta models and i don't know them
Next Topic:[Acceleo] AllInstances problem with 3.0M6
Goto Forum:
  


Current Time: Fri Apr 26 11:23:58 GMT 2024

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

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

Back to the top