|
|
Re: Generation an XMI file to java file [message #957851 is a reply to message #957597] |
Thu, 25 October 2012 14:47 |
|
Charbel,
Acceleo operates on any EMF model, not only ".ecore" ones. Generating code from your xmi file is as easy as providing them to your launch config. However, your templates have been created to operated on ecore objects (EClass, EOperation, EAttribute...). The objects from your dynamic instance are not elements applying to the ecore metamodel, but elements applying to your own metamodel (as defined in "file.ecore").
For example, you may have created a class named "Library" in your model "file.ecore". When you launch acceleo with file.ecore, generating code from that object needs a template applying to (its first parameter) EClass. When you create a dynamic instance of your "Library" class, the template that applies to that dynamic instance must have its first parameter to be of type "Library".
In other words : yes, you can generate code from your dynamic instance through Acceleo, whatever the file extension; but no, you can't use the same generators for both the Ecore metamodel and your dynamic instance (that is in fact a model which metamodel is that 'file.ecore' from which you created it).
Laurent Goubet
Obeo
|
|
|
|
Re: Generation an XMI file to java file [message #958752 is a reply to message #958090] |
Fri, 26 October 2012 07:30 |
|
Charbel,
It seems like you are not new only to Acceleo but also to EMF. Using dynamic instances correctly is not that easy without knowledge of how the EMF framework works.
Please take a look at EMF tutorials to see how you can define your model and generate at editor for it (Lars Vogel has some pretty good ones, such as http://www.vogella.com/articles/EclipseEMF/article.html). This will allow you to use a "real" model instead of a dynamic one. It will also provide you with a true "metamodel URI" to act on instead of trying to use raw XML. This will allow you to replace
[module generate('http://www.eclipse.org/emf/2003/XMLType')]
with a more sensible
[module generate('http://www.eclipse.org/myMetamodelURI')]
one, and the too generic
[template public generateElement(Library : XMLTypeDocumentRoot)]
with the customized
[template public generateElement(Library : Library)]
In other words, you will be able to define your templates customized for your metamodel instead of trying to use generic, unknown types. This will not take you much longer, but it will obviously ease your task in the long run, especially if you plan on using more than Acceleo in terms of EMF-based tools.
Laurent Goubet
Obeo
|
|
|
|
Powered by
FUDForum. Page generated in 0.04465 seconds