Skip to main content



      Home
Home » Modeling » TMF (Xtext) » beginner question
beginner question [message #1007706] Thu, 07 February 2013 03:26 Go to next message
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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
Eclipse UserFriend
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: Mon Jul 07 04:43:47 EDT 2025

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

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

Back to the top