Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » How to import ecore2ecore in template?
How to import ecore2ecore in template? [message #1286431] Sun, 06 April 2014 18:30 Go to next message
Alex Terzis is currently offline Alex TerzisFriend
Messages: 3
Registered: April 2014
Junior Member
I have a generate template based on a ecore2ecore file as in the attached.
I would like to be able to parse the Ecore2EcoreMappingRoot, and yet in the for loop I get an error "Mapping: Invalid Type".

Is there any sample template for Ecore2Ecore files that I can use?
Otherwise how could I parse an ecore2core file?

For reference, I attach my sample ecore2ecore file and my template file.

Re: How to import ecore2ecore in template? [message #1290008 is a reply to message #1286431] Wed, 09 April 2014 21:05 Go to previous messageGo to next message
Alex Terzis is currently offline Alex TerzisFriend
Messages: 3
Registered: April 2014
Junior Member
To complement my previous message, here's how the files look like:

The .ecore2ecore file is attached as nav-quantiv.ecore2ecore

--------------------------------------------------------------------------

The .mtl template file is as

[comment encoding = UTF-8 /]
[module generate('http://www.eclipse.org/emf/2004/Ecore2Ecore')]

[template public generateElement(anEcore2EcoreMappingRoot : Ecore2EcoreMappingRoot)]
[comment @main/]
[file ('test', false, 'UTF-8')]

[for (a: Mapping | anEcore2EcoreMappingRoot.nested)]

[/for]


[/file]
[/template]

--------------------------------------------------------------------------

When I hover the ".nested" part of the above in the .mtl file I get:
"[EReference] nested: Mapping[0..*]"
And yet I get the "Mapping" underlined with a red bar (error) and the error being reported in the template for the "Mapping" is:
"Invalid Type: Mapping"

Please note that the Mapping we're talking about here is the org.eclipse.emf.mapping.Mapping

--------------------------------------------------------------------------

Is Ecore2Ecore really supported by Acceleo?
Would anyone happen to have an example of a template parsing the .ecore2ecore file?
Re: How to import ecore2ecore in template? [message #1290468 is a reply to message #1290008] Thu, 10 April 2014 06:30 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

http://www.eclipse.org/emf/2004/Ecore2Ecore 'delegates' to
http://www.eclipse.org/emf/2002/Mapping. If you want to use names from
an unimported model you must either qualify them as mapping::Mapping or.
Better to just add the extra nsURI to your generate 'imports'.

Regards

Ed Willink
Re: How to import ecore2ecore in template? [message #1290562 is a reply to message #1290468] Thu, 10 April 2014 08:15 Go to previous messageGo to next message
Alex Terzis is currently offline Alex TerzisFriend
Messages: 3
Registered: April 2014
Junior Member
Using the following works well and thank you very much for your response:
[for (m: mapping::Mapping | anEcore2EcoreMappingRoot.nested)]
[/for]

Regarding the import though, when I use the following:
[import org::eclipse::emf::mapping]
I get a compilation error:
Module org::eclipse::emf::mapping not found.

Any ideas why this might happen?

Again thank you very much for getting me going; your help is greatly appreciated.
Re: How to import ecore2ecore in template? [message #1290615 is a reply to message #1290562] Thu, 10 April 2014 09:15 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

[import .../] is for MTL imports

[module generate('http://www.eclipse.org/emf/2004/Ecore2Ecore', ...)]


is for metamodel references.

Regards

Ed Willink

On 10/04/2014 09:15, Alex Terzis wrote:
> Using the following works well and thank you very much for your response:
> [for (m: mapping::Mapping | anEcore2EcoreMappingRoot.nested)]
> [/for]
>
> Regarding the import though, when I use the following:
> [import org::eclipse::emf::mapping]
> I get a compilation error:
> Module org::eclipse::emf::mapping not found.
>
> Any ideas why this might happen?
>
> Again thank you very much for getting me going; your help is greatly
> appreciated.
>
Previous Topic:Access metamodel elemnets from model
Next Topic:[Acceleo] NullPointerException in org.eclipse.acceleo.ide.ui
Goto Forum:
  


Current Time: Fri Mar 29 04:45:04 GMT 2024

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

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

Back to the top