Generating an EMF Model using XML Schema

Top    Previous: Prerequisites    Next: Generating the EMF Model Code

Step 1: Importing the Model from XML Schema

Use the XML Schema file you saved earlier: library.xsd as a sample model.

Create a new Ecore model project in the workspace:

The Ecore model "com.example.library.ecore" has the package name as its file name. The package name comes from the value of the EPackage's nsPrefix attribute is derived from the schema's target namespace (if the schema has a target namespace), or from the URI file path of the schema document if the schema does not contain a target namespace. In this sample, the "library.xsd" file includes a targetNamespace attribute that has a value of "http://www.example.com/library". Therefore, the nsPrefix attribute for the "Library" is set to "com.example.library".


Top    Previous: Prerequisites    Next: Generate the Model Code