blob: 12e9521ffbf31f440b65abb080f2277dd85e2609 [file] [log] [blame]
<html>
<head>
<meta
http-equiv="Content-Type"
content="text/html; charset=UTF-8">
<meta
http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<link
rel="stylesheet"
href="../../../..//default_style.css"
type="text/css">
<link
rel="stylesheet"
href="../../../..//webtools/wtp.css"
type="text/css">
<title>Creating XML files Tutorial</title>
</head>
<body>
<table
width="100%"
cellspacing="5"
cellpadding="2"
border="0">
<tbody>
<tr>
<td
width="60%"
align="left"><font class="indextop">Creating XML files Tutorial</font> <br>
<font class="indexsub">Creating XML files Tutorial</font></td>
<td width="40%"><img
width="207"
hspace="50"
height="129"
align="middle"
src="../../../..//webtools/images/wtplogosmall.jpg"
alt=""></td>
</tr>
</tbody>
</table>
<table
width="100%"
cellspacing="5"
cellpadding="2"
border="0">
<col width="16">
<col width="*">
<tbody>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top">
<p><b>By Ella Belisario</b> <br>
Created August 18, 2004 <br>
Updated May 11, 2007 <br>
<br>
</p>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top">
<p>This tutorial demonstrates how you can use XML documents creation wizards that come with the Eclipse
Web Tools Platform Project. These wizards allow to create XML document from DTD or XML Schema.</p>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top">
<p>After finishing this tutorial you will be able to do the following:</p>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top">
<p></p>
<ul>
<li>creating an XML file from an XML template</li>
<li>creating an XML file from an XML schema</li>
<li>creating an XML file from a DTD</li>
</ul>
<p></p>
</td>
</tr>
<tr>
<td
valign="top"
bgcolor="#0080c0"
align="left"
colspan="2"><b><font
face="Arial,Helvetica"
color="#ffffff">Getting Started</font></b></td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top">
<p>In order to work with content of this tutorial you will need to download Web Standard Tools package
from <a href="http://download.eclipse.org/webtools/downloads/"> wtp downloads. </a></p>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top">
<p>Once you have downloaded WST and prerequisites, unzip them to the same folder and you are ready to
go!</p>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top">
<p>Next, launch Eclipse workbench and select <b> File&gt;New&gt;Examples&gt;XML&gt;Editing and
validating XML files </b> to bring up the wizard to create a simple project with the sample XML files.</p>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td
valign="top"
bgcolor="#0080c0"
align="left"
colspan="2"><b><font
face="Arial,Helvetica"
color="#ffffff">Creating XML files using wizard</font></b></td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td
valign="top"
align="right"><img
width="16"
height="16"
border="0"
src="../../../..//images/Adarrow.gif"
alt=""></td>
<td><b>Creating an XML file from an XML template</b></td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top">
<p>To create an XML file from a grammar file follow these steps:</p>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top">
<ol>
<li>Invoke <b>New XML File</b> wizard using workbench menu <b>File&gt;New&gt;Other&gt;XML&gt;XML.</b>
</li>
<li>On the <b>XML File Name</b> page select a project or folder to contain the XML file and type a
name for it.</li>
<li>Next, select the option to <b>Create XML file from an XML template</b></li>
<li>On the next page, you can select an XML template (Figure 1) to use as initial content in the
XML file. The templates shown in the list come from the <b>XML Templates</b> preference page. If you
prefer no content, you can uncheck the <b>"Use XML Template"</b> checkbox to generate a blank xml file.
</li>
</ol>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><b>Figure 1: Selecting an XML template:</b></td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><img
border="0"
src="images/selectxmltemplate.png"
alt=""></td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td
valign="top"
align="right"><img
width="16"
height="16"
border="0"
src="../../../..//images/Adarrow.gif"
alt=""></td>
<td><b>Creating an XML file from DTD or XML Schema</b></td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top">
<p>Generating an XML file from a DTD or XML Schema can be useful if you want to quickly create an XML
file that is based on your gramma file.</p>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top">
<p>To create an XML file from a grammar file follow these steps:</p>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top">
<ol>
<li>Invoke <b>New XML File</b> wizard using workbench menu <b>File&gt;New&gt;Other&gt;XML&gt;XML.</b>
</li>
<li>On the <b>XML File Name</b> page select a project or folder to contain the XML file and type a
name for it.</li>
<li>Next, depending on what type of gramma file you need choose, select the <b>Create XML file
from DTD file</b> or <b>Create XML file from an XML Schema file</b> radio button.</li>
<li>The next choice you have to do is to select your gramma file. You can select it from the
workspace (you can import files into the workspace if they are not there) Another possibility is to use
DTD and XML files defined in <b>XML Catalog</b> .</li>
<li>On the <b>Select Root Element</b> page select from the following content options: <br>
<ul>
<li>Create optional attributes - both mandatory and optional attributes will be generated.</li>
<li>Create optional elements - both mandatory and optional elements will be generated.</li>
<li>Create first choice of required choice - the first option of a required choice will be
generated in your XML file.</li>
<li>Fill elements and attributes with data - any elements and attributes generated will be
filled with sample data.</li>
</ul>
<p>If you do not select any of these options, then only the minimum amount of content required for
the XML file will be created.</p>
</li>
<li>The last this is to specify document type (Figure 2) for DTD or namespace (Figure 3) for XML
Schema information.
<p>For <b>DTD:</b></p>
<ul>
<li>Specify the Public ID or System ID. You do not need to specify both. If you do, the Public
ID will be used before the System ID.</li>
</ul>
<p>For <b>XML Schema:</b></p>
<ul>
<li>The Namespace information section contains information about the target namespace of the
XML schema, its prefix, and the schema location</li>
</ul>
</li>
</ol>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><b>Figure 2: Selecting Root Element page based on DTD file:</b></td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><img
border="0"
src="images/selectRootElementDTD.png"
width="522"
height="609"
alt=""></td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><b> Figure 3: Selecting Root Element page based on XML Schema file: </b></td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><br>
</td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top"><img
border="0"
src="images/selectRootElementXSD.png"
width="526"
height="653"
alt=""></td>
</tr>
<tr>
<td
valign="top"
align="right">&nbsp;</td>
<td valign="top">
<p>When wizard finished the XML file will only contain the selected root element and any elements or
attributes contained in the root element. You can now add elements, attributes, entities, and notations to
the XML file, however, they must follow the rules established in the DTD or XML Schema file that you used to
create the XML file.</p>
</td>
</tr>
</tbody>
</table>
</body>
</html>