Step 3: Create a Model using XML

Step 3: Create a Model using XML

As the title says, data in XML-Format will be the model. And as a model has to be valid according to a meta model, the XML files must be valid according to the XSD.

In case you are not going to use an existing XML file, you can create a new one like described below. These steps require the Eclipse Web Tools Platform (WTP) to be installed.

In Eclipse, click on "File", "New", "Other..." and choose "XML" from category "XML" . After specifying a filename within folder "src" choose "create XML file from an XML Schema" and select you XML Schema Definition file. Telling Eclipse which schema to use has three advantages: Eclipse validates XML files, there is meta model aware code completion while editing and Eclipse creates a xsi:schemaLocation-attribute which tells anyone who reads the XML file where the schema file is located. This tutorial does not use the xsi:schemaLocation-attribute and introduces the schema file in the MWE workflow instead. For all possible ways see the section called “How to declare XML Schemas” . It is important that the XML file is located somewhere within the project's classpath.

<?xml version="1.0" encoding="UTF-8"?>
<wizard xmlns="http://www.example.org/wizard">
  <startpage>start</startpage>
  <name>My Example Setup</name>
  <welcometext>Welcome to this little demo application.</welcometext>
  <choicepage id="start">
    <title>Wizard Page One</title>
  </choicepage>
</wizard>