|
|
Re: [Acceleo] how to input multiple models URGENT!! [message #808155 is a reply to message #769599] |
Mon, 27 February 2012 13:15 |
fabrizio di Giuseppe Messages: 1 Registered: February 2012 |
Junior Member |
|
|
hi
I'm fabrizio
I have a problem
I did not understand how load multiple models into Acceleo file.mtl
help me please
I have a NodeSpecification.xmi model conforming to Node.ecore metamodel
how load the model into Acceleo?
how to use the command ModelUtils.Load (....)?
example:
file.mtl
[comment encoding = UTF-8 /]
[module iniFile('it.univaq.wsn.sa','it.univaq.wsn.node')]
[query public load(rec : String) : NodeSpecification = invoke('it.univaq.wsn.acceleo.common.LoadModels', 'gen(java.lang.String)', Sequence{'rec'}) /]
[template public iniGen(a : NodeSpecification)]
[comment @main /]
[file ('sample.txt', false, 'Cp1252')]
[let var : NodeSpecification = load('ciao')]
[var/]
[for (app : Node | var.nodes)]
[name/]
[/for]
[/let]
[/file]
[/template]
LoadModels.java
public class LoadModels {
public static EObject gen(String args) throws IOException, ParserConfigurationException, SAXException {
ResourceSet rs = new ResourceSetImpl();
rs.getEObject(URI.createFileURI("C:/Documents and Settings/Brizio/workspace/it.univaq.wsn.examples/nodes/NodeSpecification.xmi"), true);
EObject model = ModelUtils.load(new java.io.File("C:/Documents and Settings/Brizio/workspace/it.univaq.wsn.examples/nodes/NodeSpecification.xmi"),rs);
System.out.println(model);
}
}
|
|
|
Re: [Acceleo] how to input multiple models URGENT!! [message #808937 is a reply to message #808155] |
Tue, 28 February 2012 10:01 |
|
Hi,
If you want to generate something, remove this query (you do not load the model this way) and try something like this:
[comment encoding = UTF-8 /]
[module iniFile('it.univaq.wsn.sa','it.univaq.wsn.node')]
[template public iniGen(a : NodeSpecification)]
[comment @main /]
[file ('sample.txt', false, 'Cp1252')]
[let var : NodeSpecification = load('ciao')]
[var/]
[for (app : Node | var.nodes)]
[name/]
[/for]
[/let]
[/file]
[/template]
Then, right click on your module and select Run as -> Acceleo application. In the launch configuration, choose your model and the output folder and then click on Run. If you want to see the launch of an Acceleo generator (and loading of the input model) in video, have a look here in the second video starting at 12min48s, you will see it.
Regards,
Stephane Begaudeau, Obeo
--
Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
|
|
|
|
Powered by
FUDForum. Page generated in 0.02253 seconds