blob: ab32556c68a44a7612b9c98e8bb87275061de18c [file] [log] [blame]
<html>
<head>
<title>Step 3: Create a Model using XML</title>
<link href="book.css" rel="stylesheet" type="text/css"/>
<meta content="DocBook XSL Stylesheets V1.75.1" name="generator"/>
<link rel="home" href="index.html" title="Xpand Documentation"/>
<link rel="up" href="xsd_tutorial.html" title="XSD Tutorial"/>
<link rel="prev" href="xsd_tutorial_metamodel.html" title="Step 2: Define a Meta Model using XML Schema"/>
<link rel="next" href="xsd_tutorial_template.html" title="Step 4: Create a Template using Xpand"/>
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<h1 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">Step 3: Create a Model using XML</h1>
<div class="section" title="Step 3: Create a Model using XML">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="xsd_tutorial_model"/>Step 3: Create a Model using XML</h2>
</div>
</div>
</div>
<p>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.</p>
<p>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.</p>
<p>In Eclipse, click on <span class="emphasis">
<em>"File", "New", "Other..."</em>
</span>
and choose <span class="emphasis">
<em>"XML"</em>
</span> from category
<span class="emphasis">
<em>"XML"</em>
</span>. After specifying a filename within folder
"src" choose <span class="emphasis">
<em>"create XML file from an XML Schema"</em>
</span> 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
<span class="property">xsi:schemaLocation</span>-attribute which tells anyone who
reads the XML file where the schema file is located. This tutorial does
not use the <span class="property">xsi:schemaLocation</span>-attribute and
introduces the schema file in the MWE workflow instead. For all possible
ways see <a class="xref" href="xsd_reference_declare_xsd.html" title="How to declare XML Schemas">the section called “How to declare XML Schemas”</a> . It is important
that the XML file is located somewhere within the project's
classpath.</p>
<pre class="programlisting">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;wizard xmlns="http://www.example.org/wizard"&gt;
&lt;startpage&gt;start&lt;/startpage&gt;
&lt;name&gt;My Example Setup&lt;/name&gt;
&lt;welcometext&gt;Welcome to this little demo application.&lt;/welcometext&gt;
&lt;choicepage id="start"&gt;
&lt;title&gt;Wizard Page One&lt;/title&gt;
&lt;/choicepage&gt;
&lt;/wizard&gt;</pre>
</div>
</body>
</html>