5

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

skaffman
  • 398,947
  • 96
  • 818
  • 769
sromku
  • 4,663
  • 1
  • 36
  • 37

2 Answers2

2

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.

Ed Merks
  • 36
  • 1
  • 1
    You are right, I used XMIResourceImpl. By using: GenericXMLResourceFactoryImpl and XMLResource.OPTION_EXTENDED_META_DATA I got the solution for my question. Thanks. – sromku May 14 '11 at 18:06
  • 1
    Links: [GenericXMLResourceFactoryImpl](http://download.eclipse.org/modeling/emf/emf/javadoc/2.5.0/org/eclipse/emf/ecore/xmi/impl/GenericXMLResourceFactoryImpl.html) ; [XMLResource.OPTION_EXTENDED_META_DATA](http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/ecore/xmi/XMLResource.html) – sromku May 14 '11 at 18:17
0

You can either export the .genmodel by using the EMF tooling:

  1. Open .genmodel
  2. Choose "Export" from the generator menubar

or you can export your ecore model to a schema programmatically by using the XSDFactoryImpl.

Sandro
  • 491
  • 7
  • 20
  • In my case, I need to transform the instance (XMI) of Ecore meta-model to XML which conforms the original XSD, and not to export the Ecore meta-model to XSD as I understood from your reply. Thanks, nevertheless, I think that I found the solution. – sromku May 14 '11 at 18:12