Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » beginner question
beginner question [message #1007706] Thu, 07 February 2013 08:26 Go to next message
Claudio Persico is currently offline Claudio PersicoFriend
Messages: 24
Registered: November 2012
Junior Member
Hi to everyone,

I'm totally new to Xtext and I'm not sure if it's suited for my need.

I have a structured comma separated value file with strings and numbers like this:

["string1", 10,5,1,4]
["string2", 5,6,1,9]
etc etc.

I also have an ECORE metamodel that represents these information.

I would like to extract the information from the textual file and create an ecore model conforming to the metamodel I have.

Is it possible to do this feature with Xtext?
If yes, what can I read about?

Thanks in advance,
Claudio
Re: beginner question [message #1007735 is a reply to message #1007706] Thu, 07 February 2013 11:04 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
Hi Cladio,

xtext will generate the meta model for you.
So you could write your grammar in an .xtext and generate the code.
the examples and documentation are really good I think.
http://www.eclipse.org/Xtext/documentation.html
Cheers Christophe
Re: beginner question [message #1007751 is a reply to message #1007735] Thu, 07 February 2013 12:08 Go to previous messageGo to next message
Claudio Persico is currently offline Claudio PersicoFriend
Messages: 24
Registered: November 2012
Junior Member
Thank you for your reply,

I need the model, not the metamodel. I already have the metamodel of the output.

Do I need to define the grammar of the input (the text) and also of the output (my metamodel written in ecore)? Or I simply define only my input grammar and it translates in ecore?

Thanks in advance,

Claudio
Re: beginner question [message #1007767 is a reply to message #1007751] Thu, 07 February 2013 13:00 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
This is somewhat of an unusual case. Normally, the whole idea is to
define an xtext grammar, to obtain the meta model. So "your_csv.format".ecore

http://www.eclipse.org/Xtext/documentation.html#metamodelInference

If you already have this .ecore, then I am not sure, how you would deal with this.
Maybe the .mwe2 file can reference the existing .ecore.

Anyway, if you define the grammar, you get the .ecore so nothing to loose really. And you can compare it with your existing metamodel. The actual model, or the model instance as some like to call it will be generated when you open a file ending with instance.your_csv.format. Then the text is parsed, linked etc.. producing your instance model in an XtextResource. Actually your text file IS the model instance in a way.

This could help understanding the concept.

http://www.eclipse.org/Xtext/documentation.html#emf_integration



Re: beginner question [message #1007868 is a reply to message #1007767] Thu, 07 February 2013 20:21 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe BouhierFriend
Messages: 937
Registered: July 2009
Senior Member
actually, there is an option to start a new Xtext project from an existing .ecore. just select new -> Xtext project from existing Ecore Models.
I have never used it, but perhaps something worth checking out.
Re: beginner question [message #1007972 is a reply to message #1007751] Thu, 07 February 2013 17:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
It is possible to define a grammar for an existing metamodel (there is
even a wizard for that)
but note: you might get trouble if the metamodel and the concrete
syntax are too far from each other.

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: beginner question [message #1007980 is a reply to message #1007706] Fri, 08 February 2013 09:01 Go to previous message
Jan Koehnlein is currently offline Jan KoehnleinFriend
Messages: 760
Registered: July 2009
Location: Hamburg
Senior Member
Look for 'generated ecore model' in the Xtend docs
http://www.eclipse.org/Xtext/documentation.html#metamodelInference

Am 07.02.13 09:26, schrieb Claudio Persico:
> Hi to everyone,
>
> I'm totally new to Xtext and I'm not sure if it's suited for my need.
>
> I have a structured comma separated value file with strings and numbers
> like this:
>
> ["string1", 10,5,1,4]
> ["string2", 5,6,1,9]
> etc etc.
>
> I also have an ECORE metamodel that represents these information.
>
> I would like to extract the information from the textual file and create
> an ecore model conforming to the metamodel I have.
>
> Is it possible to do this feature with Xtext?
> If yes, what can I read about?
>
> Thanks in advance,
> Claudio


--
Need professional support for Eclipse Modeling?
Go visit: http://xtext.itemis.com


---
Get professional support from the Xtext committers at www.typefox.io
Previous Topic:Syntactic predicates in 0.8M4
Next Topic:SMI (ASN1) grammar
Goto Forum:
  


Current Time: Thu Apr 25 11:34:36 GMT 2024

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

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

Back to the top