blob: 20df2b6ea418c5126b92a661ba94f722c07e8ec6 [file] [log] [blame]
kpriceef160682006-08-29 18:08:31 +00001<?xml version="1.0" encoding="utf-8"?>
2<!--Arbortext, Inc., 1988-2005, v.4002-->
3<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
4<?Pub Inc?>
5<task id="tcrexxsd" xml:lang="en-us">
6<title>Generating XML files from XML schemas</title>
7<titlealts>
8<searchtitle>Generating an XML file from an XML schema</searchtitle>
9</titlealts>
10<shortdesc>You can generate an XML file from your XML schema if you want to
11quickly create an XML file based on your XML schema file. Generating an XML
12file from your XML schema saves you time by creating an XML file that is already
13associated with your XML schema, and contains at least some of the elements
14and attributes in your XML schema.</shortdesc>
15<prolog><metadata>
16<keywords><indexterm>XML files<indexterm>generating from XML schemas</indexterm></indexterm>
kprice9623e9d2007-05-03 03:43:05 +000017<indexterm>XML schemas<indexterm>generating XML files</indexterm></indexterm>
kpriceef160682006-08-29 18:08:31 +000018</keywords>
19</metadata></prolog>
20<taskbody>
21<context><p>After you have generated your XML file, you can further customize
22it in the XML editor.</p><p>The following instructions were written for the
23Resource perspective, but they will also work in many other perspectives.</p><p>To
24generate an XML file from a schema file follow these steps:</p></context>
25<steps>
26<step><cmd>In the Navigator view, right-click the XML schema file that you
27want to work with.</cmd></step>
28<step><cmd>From its pop-up menu click <menucascade><uicontrol>Generate</uicontrol>
29<uicontrol>XML File</uicontrol></menucascade>.</cmd></step>
30<step><cmd>Select a project or folder to contain the XML file, type a name
31for it and click <uicontrol>Next</uicontrol>.</cmd><info>The name of the file
32must end in<systemoutput>.xml.</systemoutput> </info></step>
33<step><cmd>Click the <uicontrol>Root element</uicontrol> of the XML file.</cmd>
34<info>The root element of an XML file is the element that contains all other
35elements in that file. All of the global elements you have defined in the
36XML schema will be included in the Root element list. If you do not have any
37global elements in your XML schema, you cannot create an XML file from it.</info>
38</step>
39<step><cmd>Select from the following content options:</cmd>
40<choices>
41<choice><uicontrol>Create optional attributes</uicontrol>. Both mandatory
42and optional attributes will be generated.</choice>
43<choice><uicontrol>Create optional elements</uicontrol>. Both mandatory and
44optional elements will be generated.</choice>
45<choice><uicontrol>Create first choice of required choice</uicontrol>. The
46first option of a required choice will be generated in your XML file.</choice>
47<choice><uicontrol>Fill elements and attributes with data</uicontrol>. Any
48elements and attributes generated will be filled with sample data.</choice>
49</choices>
50<info>If you do not select any of these options, then only the minimum amount
51of content required for the XML file will be created.</info></step>
52<step><cmd>The Namespace information section contains information about the
53target namespace of the XML schema, its prefix, and the schema location.</cmd>
54<info>For more information about namespaces and namespace prefixes, refer
55to the related references.</info></step>
56<step><cmd>Select the entry you want to edit and click <uicontrol>Edit</uicontrol>.</cmd>
57</step>
58<step><cmd>The value in the <uicontrol>Namespace Name</uicontrol> field is
59the target namespace of the XML schema.</cmd><info>Your XML file should be
60associated with the same namespace as its XML schema is associated with.</info>
61</step>
62<step><cmd>All qualified elements and attributes in the XML file associated
kprice9623e9d2007-05-03 03:43:05 +000063with the namespace will be prefixed with the <uicontrol>Prefix</uicontrol> value.</cmd>
kpriceef160682006-08-29 18:08:31 +000064</step>
65<step><cmd>The <uicontrol>Location Hint</uicontrol> field contains the location
66of the XML schema.</cmd></step>
67<step><cmd>Click <uicontrol>OK</uicontrol>, then <uicontrol>Finish</uicontrol>.</cmd>
68</step>
69</steps>
70<result><p>The XML file will contain the selected root element and any elements
71or attributes contained in the root element. It also contains information
72about the XML file namespace and location. You can now add elements and attributes
73to the XML file.</p><p><b>Note:</b> In certain cases, when an XML file is
74generated from a complex XML schema file, the XML file might not be valid.
75If this occurs, you can open the generated file in the XML editor and correct
76any errors that occur. Usually, only a few errors need to be fixed. The following
77XML schema constructs might present problems:</p><ol>
78<li>Restrictions. Sometimes restricted elements are erroneously generated. </li>
79<li>Facets: Default generated data values might not conform to complex facets
80(for example, patterns).</li>
81<li>Abstract elements. abstract elements are sometimes erroneously generated.</li>
82</ol></result>
83</taskbody>
84</task>
85<?Pub *0000004757?>