简体   繁体   中英

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

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)

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() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM