Is there a way to autofill a modelinstance with data? [message #1554458] |
Fri, 09 January 2015 07:49 |
René Hahn Messages: 3 Registered: January 2015 |
Junior Member |
|
|
Hello everybody,
I'm new to the EMF-World, but I've heard some lectures about it.
Currently I'm concerned with building a simple codegenerator. I know how to create a metamodel in ecore, get a instance of it to fill it with data and how to generate code with xpand.
But since a few days, I'm looking for a automated or partial-automated way to fill a XMI-modelinstance with data, i.e. from a textfile. The structure of the file is known.
So my question: Is there a way to map these informations from the textfile to a modelinstance?
It would be really annoying to fill the instance by hand, because there could be easily more than 1000 separete informations which results in a equal number of elements in the modelinstance.
To demonstrate my problem I try to explain it more exact in a simlified way:
In my metamodel is a element named "Defines".
Defines has two attributes: a "identifier" which is a EString and a "definition" which is also a EString.
My textfile could look like:
#define firstDefine "Hi, i'm the first definition."
#define secondDefine "Hi, i'm the second definition."
#define thirdDefine "Hi, i'm the thirddefinition."
I want to fill the modelinstance with exaclty this data, so there should be a concrete element of Defines with the identifier "firstDefine" and the definition "Hi, i'm the first definition.". The same with secondDefine, thirdDefine and so forth.
I hope my problem is clear for you out there.
I thought about writing a tool/plugin by myself, but before I want to make sure, that there is no other existing work for this problem.
I will also take a look at Altova MapForce, but I'm not sure if it's the tool I'm looking for. :/
Maybe I'm on the wrong track, but this is the reasion why I'm here.
I'm using Eclipse Luna with the latest versions of the EMF tools.
Greetings,
René
|
|
|
Re: Is there a way to autofill a modelinstance with data? [message #1554978 is a reply to message #1554458] |
Fri, 09 January 2015 14:33 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
René,
Comments below.
On 09/01/2015 2:30 PM, René Hahn wrote:
> Hello everybody,
>
> I'm new to the EMF-World, but I've heard some lectures about it.
> Currently I'm concerned with building a simple codegenerator. I know
> how to create a metamodel in ecore, get a instance of it to fill it
> with data and how to generate code with xpand.
>
> But since a few days, I'm looking for a automated or partial-automated
> way to fill a XMI-modelinstance with data, i.e. from a textfile. The
> structure of the file is known.
>
> So my question: Is there a way to map these informations from the
> textfile to a modelinstance? It would be really annoying to fill the
> instance by hand, because there could be easily more than 1000
> separete informations which results in a equal number of elements in
> the modelinstance.
>
> To demonstrate my problem I try to explain it more exact in a
> simlified way:
>
> In my metamodel is a element named "Defines". Defines has two
> attributes: a "identifier" which is a EString and a "definition" which
> is also a EString.
> My textfile could look like:
> #define firstDefine "Hi, i'm the first definition."
> #define secondDefine "Hi, i'm the second definition."
> #define thirdDefine "Hi, i'm the thirddefinition."
If you had an Xtext grammar for such syntax it could be used to parse
the file and create the corresponding model...
>
> I want to fill the modelinstance with exaclty this data, so there
> should be a concrete element of Defines with the identifier
> "firstDefine" and the definition "Hi, i'm the first definition.". The
> same with secondDefine, thirdDefine and so forth.
> I hope my problem is clear for you out there.
> I thought about writing a tool/plugin by myself, but before I want to
> make sure, that there is no other existing work for this problem.
> I will also take a look at Altova MapForce, but I'm not sure if it's
> the tool I'm looking for. :/
> Maybe I'm on the wrong track, but this is the reasion why I'm here. :)
I'd have a look at Xtext first. Maybe your problem is so simple that
Xtext is overkill but maybe not.
>
> I'm using Eclipse Luna with the latest versions of the EMF tools.
>
> Greetings,
> René
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03770 seconds