blob: 6a533af8c4d076f2603195943f0efe0be528aa1a [file] [log] [blame]
kpriceef160682006-08-29 18:08:31 +00001<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html lang="en-us" xml:lang="en-us">
syeshinbefd53e2005-07-27 18:16:40 +00003<head>
kpriceef160682006-08-29 18:08:31 +00004<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
kpriceb59c9f62008-04-02 21:24:37 +00005<meta name="copyright" content="Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html. Contributors: IBM Corporation - initial API and implementation" />
6<meta name="DC.rights.owner" content="(C) Copyright 2000, 2008" />
kpriceef160682006-08-29 18:08:31 +00007<meta content="public" name="security" />
8<meta content="index,follow" name="Robots" />
9<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
10<meta content="task" name="DC.Type" />
11<meta name="DC.Title" content="Generating XML files from XML schemas" />
12<meta name="abstract" content="You can generate an XML file from your XML schema if you want to quickly create an XML file based on your XML schema file. Generating an XML file from your XML schema saves you time by creating an XML file that is already associated with your XML schema, and contains at least some of the elements and attributes in your XML schema." />
13<meta name="description" content="You can generate an XML file from your XML schema if you want to quickly create an XML file based on your XML schema file. Generating an XML file from your XML schema saves you time by creating an XML file that is already associated with your XML schema, and contains at least some of the elements and attributes in your XML schema." />
kprice02ec4b02008-05-14 23:26:58 +000014<meta content="XML files, generating from XML schemas, schemas, generating XML files, XML files" name="DC.subject" />
15<meta content="XML files, generating from XML schemas, schemas, generating XML files, XML files" name="keywords" />
kpriceef160682006-08-29 18:08:31 +000016<meta scheme="URI" name="DC.Relation" content="../topics/tcretxml.html" />
17<meta scheme="URI" name="DC.Relation" content="../topics/tcrexdtd.html" />
18<meta scheme="URI" name="DC.Relation" content="../topics/txedttag.html" />
19<meta scheme="URI" name="DC.Relation" content="../topics/cwxmledt.html" />
20<meta scheme="URI" name="DC.Relation" content="../../org.eclipse.wst.xsdeditor.doc.user/topics/rnmspc.html" />
21<meta content="XHTML" name="DC.Format" />
22<meta content="tcrexxsd" name="DC.Identifier" />
23<meta content="en-us" name="DC.Language" />
24<link href="../../org.eclipse.wst.doc.user/common.css" type="text/css" rel="stylesheet" />
syeshinbefd53e2005-07-27 18:16:40 +000025<title>Generating an XML file from an XML schema</title>
syeshin66078272005-09-20 16:53:38 +000026</head>
syeshinbefd53e2005-07-27 18:16:40 +000027<body id="tcrexxsd"><a name="tcrexxsd"><!-- --></a>
28
kpriceef160682006-08-29 18:08:31 +000029
syeshind0bdb8e2005-10-27 17:44:14 +000030<h1 class="topictitle1">Generating XML files from XML schemas</h1>
kpriceef160682006-08-29 18:08:31 +000031
32
33
34
syeshind0bdb8e2005-10-27 17:44:14 +000035<div><p>You can generate an XML file from your XML schema if you want to
36quickly create an XML file based on your XML schema file. Generating an XML
37file from your XML schema saves you time by creating an XML file that is already
38associated with your XML schema, and contains at least some of the elements
39and attributes in your XML schema.</p>
kpriceef160682006-08-29 18:08:31 +000040
syeshind0bdb8e2005-10-27 17:44:14 +000041<div class="section"><p>After you have generated your XML file, you can further customize
42it in the XML editor.</p>
kpriceef160682006-08-29 18:08:31 +000043<p>The following instructions were written for the
44Resource perspective, but they will also work in many other perspectives.</p>
45<p>To
46generate an XML file from a schema file follow these steps:</p>
syeshinbefd53e2005-07-27 18:16:40 +000047</div>
kpriceef160682006-08-29 18:08:31 +000048
49<ol>
50<li class="stepexpand"><span>In the Navigator view, right-click the XML schema file that you
kpriceb59c9f62008-04-02 21:24:37 +000051want to work with and select <span class="menucascade"><span class="uicontrol">Generate</span>
kpriceef160682006-08-29 18:08:31 +000052 &gt; <span class="uicontrol">XML File</span></span>.</span></li>
53
kpriceb59c9f62008-04-02 21:24:37 +000054<li class="stepexpand"><span>Select a project or folder to contain the XML file and type a name
55for the file in the <span class="uicontrol">File Name</span> field, then click <span class="uicontrol">Next</span>.</span>
56 The name of the file must end in <kbd class="userinput">.xml</kbd>.
57</li>
kpriceef160682006-08-29 18:08:31 +000058
kpriceb59c9f62008-04-02 21:24:37 +000059<li class="stepexpand"><span>Select the <span class="uicontrol">Root element</span> of the XML file.</span>
kpriceef160682006-08-29 18:08:31 +000060 The root element of an XML file is the element that contains all other
syeshinbefd53e2005-07-27 18:16:40 +000061elements in that file. All of the global elements you have defined in the
kpriceef160682006-08-29 18:08:31 +000062XML schema will be included in the Root element list. If you do not have any
63global elements in your XML schema, you cannot create an XML file from it.
64</li>
65
66<li class="stepexpand"><span>Select from the following content options:</span>
67<ul>
kpriceb59c9f62008-04-02 21:24:37 +000068<li><span class="uicontrol">Create optional attributes</span>: both mandatory
kpriceef160682006-08-29 18:08:31 +000069and optional attributes will be generated.</li>
70
kpriceb59c9f62008-04-02 21:24:37 +000071<li><span class="uicontrol">Create optional elements</span>: both mandatory and
syeshinbefd53e2005-07-27 18:16:40 +000072optional elements will be generated.</li>
kpriceef160682006-08-29 18:08:31 +000073
kpriceb59c9f62008-04-02 21:24:37 +000074<li><span class="uicontrol">Create first choice of required choice</span>: the
kpriceef160682006-08-29 18:08:31 +000075first option of a required choice will be generated in your XML file.</li>
76
kpriceb59c9f62008-04-02 21:24:37 +000077<li><span class="uicontrol">Fill elements and attributes with data</span>: any
syeshinbefd53e2005-07-27 18:16:40 +000078elements and attributes generated will be filled with sample data.</li>
kpriceef160682006-08-29 18:08:31 +000079
syeshinbefd53e2005-07-27 18:16:40 +000080</ul>
kpriceef160682006-08-29 18:08:31 +000081
syeshinbefd53e2005-07-27 18:16:40 +000082 If you do not select any of these options, then only the minimum amount
83of content required for the XML file will be created.</li>
kpriceef160682006-08-29 18:08:31 +000084
kpriceb59c9f62008-04-02 21:24:37 +000085<li class="stepexpand"><span>The Namespace Information section contains information about the
86target namespace of the XML schema, its prefix, and the schema location. Select
87the entry you want to edit and click <span class="uicontrol">Edit</span>.</span> <ul>
88<li>The value in the <span class="uicontrol">Namespace Name</span> field is the target
89namespace of the XML schema. Your XML file should be associated with the same
90namespace as its XML schema is associated with.</li>
kpriceef160682006-08-29 18:08:31 +000091
kpriceb59c9f62008-04-02 21:24:37 +000092<li>All qualified elements and attributes in the XML file associated with
93the namespace will be prefixed with the <span class="uicontrol">Prefix</span> value.</li>
kpriceef160682006-08-29 18:08:31 +000094
kpriceb59c9f62008-04-02 21:24:37 +000095<li>The <span class="uicontrol">Location Hint</span> field contains the location
96of the XML schema.</li>
kpriceef160682006-08-29 18:08:31 +000097
kpriceb59c9f62008-04-02 21:24:37 +000098</ul>
99For more information about namespaces and namespace prefixes, refer to
100the related references.</li>
kpriceef160682006-08-29 18:08:31 +0000101
kpriceb59c9f62008-04-02 21:24:37 +0000102<li class="stepexpand"><span>Click <span class="uicontrol">OK</span> and then <span class="uicontrol">Finish</span>.</span>
kpriceef160682006-08-29 18:08:31 +0000103</li>
104
syeshinbefd53e2005-07-27 18:16:40 +0000105</ol>
kpriceef160682006-08-29 18:08:31 +0000106
107<div class="section"><p>The XML file will contain the selected root element and any elements
108or attributes contained in the root element. It also contains information
109about the XML file namespace and location. You can now add elements and attributes
110to the XML file.</p>
kpriceb59c9f62008-04-02 21:24:37 +0000111<div class="note"><span class="notetitle">Note:</span> In certain cases, when an XML file is generated
112from a complex XML schema file, the XML file might not be valid. If this occurs,
113you can open the generated file in the XML editor and correct any errors that
114occur. Usually, only a few errors need to be fixed. The following XML schema
115constructs might present problems:</div>
116<ul>
117<li>Restrictions: sometimes restricted elements are erroneously generated. </li>
kpriceef160682006-08-29 18:08:31 +0000118
kpriceb59c9f62008-04-02 21:24:37 +0000119<li>Facets: default generated data values might not conform to complex facets
syeshinbefd53e2005-07-27 18:16:40 +0000120(for example, patterns).</li>
kpriceef160682006-08-29 18:08:31 +0000121
kpriceb59c9f62008-04-02 21:24:37 +0000122<li>Abstract elements: abstract elements are sometimes erroneously generated.</li>
kpriceef160682006-08-29 18:08:31 +0000123
kpriceb59c9f62008-04-02 21:24:37 +0000124</ul>
syeshinbefd53e2005-07-27 18:16:40 +0000125</div>
kpriceef160682006-08-29 18:08:31 +0000126
syeshinbefd53e2005-07-27 18:16:40 +0000127</div>
128
kpriceef160682006-08-29 18:08:31 +0000129<div><div class="relconcepts"><strong>Related concepts</strong><br />
130<div><a href="../topics/cwxmledt.html" title="The XML editor is a tool for creating and viewing XML files.">XML editor</a></div>
syeshin66078272005-09-20 16:53:38 +0000131</div>
kpriceef160682006-08-29 18:08:31 +0000132<div class="reltasks"><strong>Related tasks</strong><br />
kprice0d617d02007-04-05 04:02:49 +0000133<div><a href="../topics/tcretxml.html" title="You can create a new XML file which you can then edit in the XML editor. You create a new XML file that is not associated with a DTD or XML schema file, so there are no restrictions on the kind of content it can contain.">Creating XML files</a></div>
kpriceef160682006-08-29 18:08:31 +0000134<div><a href="../topics/tcrexdtd.html" title="You can generate an XML file from your DTD if you want to quickly create an XML file based on your DTD file. Generating an XML file from your DTD saves you time by creating an XML file that is already associated with your DTD, and contains at least some of the elements and attributes in your DTD.">Generating XML files from DTDs</a></div>
135<div><a href="../topics/txedttag.html" title="This file contains information about editing XML files.">Editing XML files</a></div>
136</div>
137<div class="relinfo"><strong>Related information</strong><br />
138<div><a href="../../org.eclipse.wst.xsdeditor.doc.user/topics/rnmspc.html">XML namespaces</a></div>
139</div>
140</div>
141
syeshinbefd53e2005-07-27 18:16:40 +0000142</body>
143</html>