blob: 6ba3873eb01fde0c7c5a5e98aeb1a303bee27deb [file] [log] [blame]
kpriceef160682006-08-29 18:08:31 +00001<?xml version="1.0" encoding="utf-8"?>
kpriceb59c9f62008-04-02 21:24:37 +00002<!--Arbortext, Inc., 1988-2006, v.4002-->
4 "task.dtd">
kpriceef160682006-08-29 18:08:31 +00005<task id="tcrexxsd" xml:lang="en-us">
6<title>Generating XML files from XML schemas</title>
8<searchtitle>Generating an XML file from an XML schema</searchtitle>
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>
kprice02ec4b02008-05-14 23:26:58 +000016<keywords><indexterm keyref="tcrexxsd|1|XMLfilesgeneratingfromXMLschemas"
17status="new">XML files<indexterm>generating from XML schemas</indexterm></indexterm>
18<indexterm keyref="tcrexxsd|2|XMLschemasgeneratingXMLfiles" status="changed">schemas<indexterm>generating
19XML files</indexterm></indexterm></keywords>
21<keywords><indexterm keyref="tcrexxsd|11|XMLfilesschemas" status="new">XML
kpriceef160682006-08-29 18:08:31 +000023</metadata></prolog>
25<context><p>After you have generated your XML file, you can further customize
26it in the XML editor.</p><p>The following instructions were written for the
27Resource perspective, but they will also work in many other perspectives.</p><p>To
28generate an XML file from a schema file follow these steps:</p></context>
30<step><cmd>In the Navigator view, right-click the XML schema file that you
kpriceb59c9f62008-04-02 21:24:37 +000031want to work with and select <menucascade><uicontrol>Generate</uicontrol>
kpriceef160682006-08-29 18:08:31 +000032<uicontrol>XML File</uicontrol></menucascade>.</cmd></step>
kpriceb59c9f62008-04-02 21:24:37 +000033<step><cmd>Select a project or folder to contain the XML file and type a name
34for the file in the <uicontrol>File Name</uicontrol> field, then click <uicontrol>Next</uicontrol>.</cmd>
35<info>The name of the file must end in <userinput>.xml</userinput>.</info>
37<step><cmd>Select the <uicontrol>Root element</uicontrol> of the XML file.</cmd>
kpriceef160682006-08-29 18:08:31 +000038<info>The root element of an XML file is the element that contains all other
39elements in that file. All of the global elements you have defined in the
40XML schema will be included in the Root element list. If you do not have any
41global elements in your XML schema, you cannot create an XML file from it.</info>
43<step><cmd>Select from the following content options:</cmd>
kpriceb59c9f62008-04-02 21:24:37 +000045<choice><uicontrol>Create optional attributes</uicontrol>: both mandatory
kpriceef160682006-08-29 18:08:31 +000046and optional attributes will be generated.</choice>
kpriceb59c9f62008-04-02 21:24:37 +000047<choice><uicontrol>Create optional elements</uicontrol>: both mandatory and
kpriceef160682006-08-29 18:08:31 +000048optional elements will be generated.</choice>
kpriceb59c9f62008-04-02 21:24:37 +000049<choice><uicontrol>Create first choice of required choice</uicontrol>: the
kpriceef160682006-08-29 18:08:31 +000050first option of a required choice will be generated in your XML file.</choice>
kpriceb59c9f62008-04-02 21:24:37 +000051<choice><uicontrol>Fill elements and attributes with data</uicontrol>: any
kpriceef160682006-08-29 18:08:31 +000052elements and attributes generated will be filled with sample data.</choice>
54<info>If you do not select any of these options, then only the minimum amount
55of content required for the XML file will be created.</info></step>
kpriceb59c9f62008-04-02 21:24:37 +000056<step><cmd>The Namespace Information section contains information about the
57target namespace of the XML schema, its prefix, and the schema location. Select
58the entry you want to edit and click <uicontrol>Edit</uicontrol>.</cmd><info><ul>
59<li>The value in the <uicontrol>Namespace Name</uicontrol> field is the target
60namespace of the XML schema. Your XML file should be associated with the same
61namespace as its XML schema is associated with.</li>
62<li>All qualified elements and attributes in the XML file associated with
63the namespace will be prefixed with the <uicontrol>Prefix</uicontrol> value.</li>
64<li>The <uicontrol>Location Hint</uicontrol> field contains the location
65of the XML schema.</li>
66</ul>For more information about namespaces and namespace prefixes, refer to
67the related references.</info></step>
68<step><cmd>Click <uicontrol>OK</uicontrol> and then <uicontrol>Finish</uicontrol>.</cmd>
kpriceef160682006-08-29 18:08:31 +000069</step>
71<result><p>The XML file will contain the selected root element and any elements
72or attributes contained in the root element. It also contains information
73about the XML file namespace and location. You can now add elements and attributes
kpriceb59c9f62008-04-02 21:24:37 +000074to the XML file.</p><note>In certain cases, when an XML file is generated
75from a complex XML schema file, the XML file might not be valid. If this occurs,
76you can open the generated file in the XML editor and correct any errors that
77occur. Usually, only a few errors need to be fixed. The following XML schema
kprice02ec4b02008-05-14 23:26:58 +000078constructs might present problems:</note><ul>
kpriceb59c9f62008-04-02 21:24:37 +000079<li>Restrictions: sometimes restricted elements are erroneously generated. </li>
80<li>Facets: default generated data values might not conform to complex facets
kpriceef160682006-08-29 18:08:31 +000081(for example, patterns).</li>
kpriceb59c9f62008-04-02 21:24:37 +000082<li>Abstract elements: abstract elements are sometimes erroneously generated.</li>
kpriceef160682006-08-29 18:08:31 +000084</taskbody>