Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » beginner question
beginner question [message #1007706] Thu, 07 February 2013 03:26 Go to next message
Claudio Persico is currently offline Claudio Persico
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 06:04 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 897
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 07:08 Go to previous messageGo to next message
Claudio Persico is currently offline Claudio Persico
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 08:00 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 897
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 15:21 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 897
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 12:48 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian Dietrich
Messages: 6144
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
Re: beginner question [message #1007980 is a reply to message #1007706] Fri, 08 February 2013 04:01 Go to previous message
Jan Koehnlein is currently offline Jan Koehnlein
Messages: 655
Registered: July 2009
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
Previous Topic:Syntactic predicates in 0.8M4
Next Topic:SMI (ASN1) grammar
Goto Forum:
  


Current Time: Thu Jul 31 13:52:31 EDT 2014

Powered by FUDForum. Page generated in 0.02781 seconds