# Step 2: Define a Meta Model using XML Schema

In case you are not going to use an existing XML Schema Definition, you can create a new a new one like described below. These steps make use of the Eclipse Web Tools Platform (WTP) to have fancy editors.

In Eclipse, click on "File", "New", "Other..." and choose "XML Schema" from category "XML". Select the project's "src" folder and specify a filename. Clicking on "finish" creates an empty XSD file. It is important that the XSD file is located somewhere within the project's classpath.

This XML Schema consists of two complex data types, which contain some elements and attributes. "complex" in the XSD terminology means that as opposed to simple data types that they can actually have sub-elements and/or attributes. This example is too minimalistic to do anything useful.

The complex Type `Wizard` contains the elements `startpage` , `name` , `welcometext` , and `choicepage` . Except for `choicepage` all elements have to contain strings, whereas the string of `startpage` must be a valid id of any `ChoicePage` . The complex type `ChoicePage` just contains an `id` and a `name` . For Xpand it does not make any difference if something is modeled as an XML-attribute or XML-element. Just the datafield's type defines how Xpand treats the value.

To get an overview how schemas can be used by the Xpand XSD Adapter, see the section called “How to declare XML Schemas”

Internally, the Xpand XSD Adapter transforms the XSD model to an Ecore model which Xpand can use like any other Ecore model. For more information about that, see the section called “Behind the scenes: Transforming XSD to Ecore”

Figure 4. WTP Schema Editor

    <?xml version="1.0" encoding="UTF-8"?>
    <schema xmlns="http://www.w3.org/2001/XMLSchema"
      targetNamespace="http://www.example.org/wizard"
      xmlns:tns="http://www.example.org/wizard"
      elementFormDefault="qualified">

      <complexType name="Wizard">
        <sequence>
          <element name="startpage" type="IDREF" />
          <element name="name" type="string" />
          <element name="welcometext" type="string" />
          <element name="choicepage" type="tns:ChoicePage" />
        </sequence>
      </complexType>

      <complexType name="ChoicePage">
        <sequence>
          <element name="title" type="string" />
        </sequence>
        <attribute name="id" type="ID" />
      </complexType>

      <element name="wizard" type="tns:Wizard" />
    </schema>