# Step 5: Create a Workflow

The workflow ties together model, meta model and templates and defines the process of how to generate code.

To create a new workflow file, switch to the Xpand/Xtend perspective, click on "File", "New" and "Workflow file" . After specifying a folder and a filename an empty workflow is created.

The minimalistic approach consists of two steps:

1. Read the Model: This is done by `org.eclipse.xtend.typesystem.xsd.XMLReader` . It needs exactly one `uri` element which defines the XML file. A further nested element of type `org.eclipse.xtend.typesystem.xsd.XSDMetaModel` tells the `XMLReader` which metamodel to use. `XSDMetaModel` can contain multiple `schemaFile` elements. How the schemas are used for the XML file is determined based on the declared namespaces. `modelSlot` defines a location where the model is stored internally, this is like a variable name which becomes important if you want to handle multiple models within the same workflow.

2. Generate Code: This part just does the regular code generation using Xpand and is not specific to the Xpand XSD Adapter at all. The generator `org.eclipse.xpand2.Generator` needs to know which meta model to use. This example references the previously declared one. The `expand` element tells the generator to call the definition named `Root` within file `template.xpt` using the contents of slot `model` as parameter. Element `outlet` defines where to store the generates files.

    <workflow>
      <component class="org.eclipse.xtend.typesystem.xsd.XMLReader">
        <modelSlot value="model" />
        <uri value="model.xml" />
        <metaModel id="mm"
          class="org.eclipse.xtend.typesystem.xsd.XSDMetaModel">
          <schemaFile value="metamodel.xsd" />
        </metaModel>
      </component>
      <component class="org.eclipse.xpand2.Generator">
        <metaModel idRef="mm" />
        <expand value="template::Root FOR model" />
        <outlet path="src-gen" />
      </component>
    </workflow>