xmlxmieclipse-emfeclipse-emf-ecore

How to convert an XMI model-instance of Ecore to XML of the given XSD?


I am using the Ecore model which is based on imported XML Schema file (XSD). Using generated Java classes (based on Ecore model), I build an instance of the model and save it as a resource in XMI standard. This XMI file is actually an XML file which conforms to the Ecore model.

Questions:
Is it possible to convert the instance of the Ecore model from XMI format to XML format that conforms to the original XML Schema (XSD)?

Which sdks/frameworks/plugins can provide such conversion?

Thanks


Solution

  • If you make sure you save the instance using the resource created by the generated XyzResourceFactoryImpl it should produce results that conform to your schema. It sounds like you saved using an XMIResourceImpl. Try invoking Generate Test Code and look at the generated XyzExample.java for how to ensure you're using the right resource implementation with the right save/load options.