Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » xtext models as ecore
xtext models as ecore [message #697104] Fri, 15 July 2011 14:35 Go to next message
chuck  is currently offline chuck Friend
Messages: 160
Registered: July 2010
Senior Member
HI everybody!

I'm interested to know if it's possible to inject or extract from xtext models (written by xtext) to ecore and opposite...

For example :
I write my grammar in xtext and I got the metamodel of my grammar... launching the other eclipse instance I can write textual models using my grammar definition... now...I would like to know if I could extract an ecore model of my textual model...

thx so much
Re: xtext models as ecore [message #697115 is a reply to message #697104] Fri, 15 July 2011 14:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

I do not really understand what your problem is. An Xtext model is
ecore based. So what is what you want to do? Did you read the
documentation section on Processing Xtext models? Regards Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext models as ecore [message #697121 is a reply to message #697115] Fri, 15 July 2011 15:16 Go to previous messageGo to next message
chuck  is currently offline chuck Friend
Messages: 160
Registered: July 2010
Senior Member
I know that the models written conforms to my grammar can be parsed or can be passed to expand template to generate text...I need an ecore representation of these textual models ...
Thx
Re: xtext models as ecore [message #697125 is a reply to message #697121] Fri, 15 July 2011 15:21 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi, please define ecore representation.~Christian

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext models as ecore [message #697127 is a reply to message #697121] Fri, 15 July 2011 15:32 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 7/15/11 5:16 PM, chuck wrote:
> I know that the models written conforms to my grammar can be parsed or
> can be passed to expand template to generate text...I need an ecore
> representation of these textual models ...
> Thx

A meta model (.ecore file) is derived from the grammar or an existing
meta model is imported and used in the grammar.

A text is parsed into a model.

A model can be constructed programatically.
The model can be modified textually or structured.

The model can be serialized as text (conforming to the grammar).
The model can be serialized in some other format (XMI).

You would only need to save it as XMI (or some other universal format)
if you need to send it off to a context where the parser is not available.

If the parser is available, it is possible to reference the elements of
the model (parsed from text) just as any other model.

Does that help?

- henrik
Re: xtext models as ecore [message #697128 is a reply to message #697127] Fri, 15 July 2011 15:38 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Here is Sample Code for that: http://www.eclipse.org/forums/index.php/mv/msg/207930/666091/#msg_666091

Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: xtext models as ecore [message #697129 is a reply to message #697127] Fri, 15 July 2011 15:43 Go to previous messageGo to next message
chuck  is currently offline chuck Friend
Messages: 160
Registered: July 2010
Senior Member
@You would only need to save it as XMI (or some other universal format)

exactly!! that's I wanna do!!
I have to process and build programmatically? there is no one operation like in TCS able to inject into an xmi file?
Re: xtext models as ecore [message #697134 is a reply to message #697129] Fri, 15 July 2011 15:55 Go to previous messageGo to next message
Henrik Lindberg is currently offline Henrik LindbergFriend
Messages: 2509
Registered: July 2009
Senior Member
On 7/15/11 5:43 PM, chuck wrote:
> @You would only need to save it as XMI (or some other universal format)
> exactly!! that's I wanna do!!
> I have to process and build programmatically? there is no one operation
> like in TCS able to inject into an xmi file?

Christian provided a link to a forum thread that shows how it is done.
And yes, you need a small snippet of code to get it done. You can do it
as a builder, a save hook (both would ensure that the xmi version of the
content is always there), or you may want it as an action in the editor
menu, or as an export wizard, etc. All depends on what/why you are doing
this.

Normally, having the resource as an extra copy in a file in xmi format
is not very useful.

Regards
- henrik
Re: xtext models as ecore [message #697138 is a reply to message #697134] Fri, 15 July 2011 16:10 Go to previous message
chuck  is currently offline chuck Friend
Messages: 160
Registered: July 2010
Senior Member
Oh sorry I didn t see the link...(mobile )
Previous Topic:Adding implicitly created objects to model
Next Topic:Matching start/end tags
Goto Forum:
  


Current Time: Fri Apr 26 02:29:32 GMT 2024

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

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

Back to the top