Home » Archived » M2M (model-to-model transformation) » [ATL] Xtext as input for ATL M2M
| |
Re: [ATL] Xtext as input for ATL M2M [message #503959 is a reply to message #503952] |
Wed, 16 December 2009 15:53 |
Tim Messages: 7 Registered: December 2009 |
Junior Member |
|
|
Hi Alfons,
I made the changes you suggested. But now I receive the error message that certain classes (defined in my metamodel) can not be found in reference model Xtext.
And if I use the .xmi file as model file, what do I do with my actual model. The .xmi was automatically generated from the Xtext. The model that I made afterwards in the created text editor, is probably not incorporated in the .xmi, is it?
Do you have any other suggestions?
Regards,
Tim
[Updated on: Wed, 16 December 2009 16:13] Report message to a moderator
|
|
| | | |
Re: [ATL] Xtext as input for ATL M2M [message #504127 is a reply to message #504091] |
Thu, 17 December 2009 11:23 |
Alfons Laarman Messages: 35 Registered: July 2009 |
Member |
|
|
The problem is indeed that you use the text file as input. Somehow you have
to get a hold of the parsed xmi version, which is used behind the scenes by
the the sample reflective ecore editor.
For a simple solution you better ask the xtext guys in the tmf group. A
dirty option is to edit the generated plugins.
Regards,
Alfons
On 12/17/09 9:39 AM, in article hgcqni$281$1@build.eclipse.org, "Tim"
<tim1985z@yahoo.com> wrote:
> I am trying to do apply an ATL M2M transformation to a file created with a
> text editor created with Xtext.
>
> In order to do that I started with an Xtext project. In that project I changed
> the available (standard) .xtext file so that I could define my own grammar.
> Then using GenerateCif.mwe (Cif is the file-extension I have defined), the
> ecore metamodel, genmodel and .xmi file are automatically created in the
> src-gen folder of the Xtext project.
>
> When I start a second Eclipse application, so that the plugins I just created
> are available, I can open a text file in the cif text editor. In this text
> file I typed the model that I would like to transform. All this goes well, I
> can even open the model (text file) with Sample Ecore Model editor.
>
> But if I want to transform this model(text file) using an ATL M2M
> transformation I receive the error that No Resource can be found. I have used
> the automatically created ecore metamodel in the src-gen folder of the Xtext
> project as metamodel in the transformation and the model(text file) as input
> file.
>
> So I think that the problem is that the model(text file) can not be read
> correctly by ATL. So does anybody have an idea to fix this.
>
> I hope this clarifies the problem.
>
> Regards,
>
> Tim
|
|
| | |
Re: [ATL] Xtext as input for ATL M2M [message #505677 is a reply to message #505637] |
Mon, 04 January 2010 07:58 |
Alfons Laarman Messages: 35 Registered: July 2009 |
Member |
|
|
Hi Shannon,
Guillaume offered the right solution:
" Your model needs to be loaded as an XtextResource, you can do it easily in
Java, see:
http://wiki.eclipse.org/Xtext/FAQ#How_do_I_load_my_model_in_ a_standalone_Jav
a_application_.3F
Once you got the Resource, you can execute the ATL transformation with the
Java ATL API. "
Although I don't think that directly supplying the loaded model to the ATL
API will work. ATL requires models to be loaded with a internal model
handler. This model handler, in my experience, cannot cope with EMF
generated models.
I created this feature request for the issue:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=298328
A temporary solution for you would be to store the model to disk first and
then use it in your ATL transformation.
Cheers,
Alfons
On 1/4/10 12:05 AM, in article hhr7rh$1bl$1@build.eclipse.org, "Shannon"
<shannonbay@gmail.com> wrote:
> Hi Tim,
>
> Did the Xtext guys offer a solution for this problem? This is exactly the
> issue that I am having.
>
> Cheers,
>
> Shannon
|
|
| |
Re: [ATL] Xtext as input for ATL M2M [message #506328 is a reply to message #505723] |
Thu, 07 January 2010 01:26 |
Shannon Messages: 6 Registered: December 2009 Location: Wellington, NZ |
Junior Member |
|
|
Hm, I couldn't get the ATL wrapper code that Guillaume suggested to work. I guess I don't have that api or something? I'm using the full Eclipse modelling package though so it seems odd.
Anyway, I'm reasonably happy for now... I was able to save the ecore xmi model to disk as Alfons suggested, using the following code:
package org.xtext.example;
import java.io.IOException;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
import org.eclipse.xtext.resource.XtextResourceSet;
public class ModelGenerator {
/**
* @param args
*/
public static void main(String[] args) {
PropStandaloneSetup.doSetup();
XtextResourceSet resourceSet = new XtextResourceSet();
URI uri = URI.createURI("src/test.prop");
Resource xtextResource = resourceSet.getResource(uri , true);
Resource xmiResource = new EcoreResourceFactoryImpl().createResource(URI.createURI("src/test.ecore"));
xmiResource.getContents().add(xtextResource.getContents().get(0));
try {
xmiResource.save(null);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
I can then run transformations on that code in either my DSL plugin version of eclipse, if I also copy over the metamodel, or in the normal version.
This is not a long term solution, but for now I am simply evaluating ATL + xText.
Cheers,
Shannon
|
|
|
Re: [ATL] Xtext as input for ATL M2M [message #506629 is a reply to message #506328] |
Fri, 08 January 2010 12:40 |
Alfons Laarman Messages: 35 Registered: July 2009 |
Member |
|
|
Shannon,
You should import the right plugins for your project:
- org.eclipse.m2m.atl.engine.emfvm
- org.eclipse.m2m.atl.core.service.CoreService
At least in my setup, I couldnt get Guillaumes code to run yet. I did a
bunch of function calls to the EMFModelFactory to make sure the right
EPackages are registered etc. Now I run into nasty bugs, which im currently
debugging. In my opinion there are like a kazillion ways to use the
CoreService in the wrong way, just because the interface doesn't make enough
EMF things implicit.
So I would advice you to store the model and reload it when you call ATL
programmatically. An example of how to do that, you can find in the ATL
example privatization.
If you however make progress with using the model directly, please keep me
posted.
Regards,
Alfons
On 1/7/10 2:27 AM, in article hi3d97$1cq$1@build.eclipse.org, "Shannon"
<shannonbay@gmail.com> wrote:
> Hm, I couldn't get the ATL wrapper code that Guillaume suggested to work. I
> guess I don't have that api or something? I'm using the full Eclipse
> modelling package though so it seems odd.
>
> Anyway, I'm reasonably happy for now... I was able to save the ecore xmi
> model to disk as Alfons suggested, using the following code:
>
> package org.xtext.example;
>
> import java.io.IOException;
>
> import org.eclipse.emf.common.util.URI;
> import org.eclipse.emf.ecore.resource.Resource;
> import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
> import org.eclipse.xtext.resource.XtextResourceSet;
>
> public class ModelGenerator {
>
> /**
> * @param args
> */
> public static void main(String[] args) {
> PropStandaloneSetup.doSetup();
> XtextResourceSet resourceSet = new XtextResourceSet();
> URI uri = URI.createURI("src/test.prop");
> Resource xtextResource = resourceSet.getResource(uri , true);
> Resource xmiResource = new
> EcoreResourceFactoryImpl().createResource(URI.createURI("src/test.ecore "));
> xmiResource.getContents().add(xtextResource.getContents().ge t(0));
> try {
> xmiResource.save(null);
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> }
>
> }
>
> I can then run transformations on that code in either my DSL plugin version of
> eclipse, if I also copy over the metamodel, or in the normal version.
>
> This is not a long term solution, but for now I am simply evaluating ATL +
> xText.
>
> Cheers,
>
> Shannon
|
|
| | | | |
Goto Forum:
Current Time: Wed Sep 25 02:40:43 GMT 2024
Powered by FUDForum. Page generated in 0.06003 seconds
|