Fhl
Fhl

Reputation: 1193

How to create an instance of an ecore file programmatically

I am trying to create an instance of an ecore file so I can store data in it. I will serialize it and store it as XMI (and then load it if it exist). In my case I cannot use genmodel and "create dynamic instance". I found this tutorial which create the ecore model itself programmatically, but I want to load an ecore file and then create an instance of it using some general factory.

How can I achieve this?

Thank you for your time and help

Upvotes: 0

Views: 1849

Answers (2)

Christian Dietrich
Christian Dietrich

Reputation: 11868

you may have a look at http://www.ibm.com/developerworks/library/os-eclipse-dynamicemf/index.html

(with the difference of getting the eclasses and estructural features by reading the ecore)

Upvotes: 1

Fabien Fleureau
Fabien Fleureau

Reputation: 693

In the tutorial they use ResourceSet.createResource() to create a new resource.

If you want to load an existing resource, you should try ResourceSet.getResource().

Upvotes: 0

Related Questions