blob: afb257c16b713cd94726de1c2aab4db79caa4dc8 [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-->
3<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN"
4 "task.dtd">
kpriceef160682006-08-29 18:08:31 +00005<?Pub Inc?>
6<task id="tcrexxsd" xml:lang="en-us">
7<title>Generating XML files from XML schemas</title>
8<titlealts>
9<searchtitle>Generating an XML file from an XML schema</searchtitle>
10</titlealts>
11<shortdesc>You can generate an XML file from your XML schema if you want to
12quickly create an XML file based on your XML schema file. Generating an XML
13file from your XML schema saves you time by creating an XML file that is already
14associated with your XML schema, and contains at least some of the elements
15and attributes in your XML schema.</shortdesc>
16<prolog><metadata>
17<keywords><indexterm>XML files<indexterm>generating from XML schemas</indexterm></indexterm>
kprice9623e9d2007-05-03 03:43:05 +000018<indexterm>XML schemas<indexterm>generating XML files</indexterm></indexterm>
kpriceef160682006-08-29 18:08:31 +000019</keywords>
20</metadata></prolog>
21<taskbody>
22<context><p>After you have generated your XML file, you can further customize
23it in the XML editor.</p><p>The following instructions were written for the
24Resource perspective, but they will also work in many other perspectives.</p><p>To
25generate an XML file from a schema file follow these steps:</p></context>
26<steps>
27<step><cmd>In the Navigator view, right-click the XML schema file that you
kpriceb59c9f62008-04-02 21:24:37 +000028want to work with and select <menucascade><uicontrol>Generate</uicontrol>
kpriceef160682006-08-29 18:08:31 +000029<uicontrol>XML File</uicontrol></menucascade>.</cmd></step>
kpriceb59c9f62008-04-02 21:24:37 +000030<step><cmd>Select a project or folder to contain the XML file and type a name
31for the file in the <uicontrol>File Name</uicontrol> field, then click <uicontrol>Next</uicontrol>.</cmd>
32<info>The name of the file must end in <userinput>.xml</userinput>.</info>
33</step>
34<step><cmd>Select the <uicontrol>Root element</uicontrol> of the XML file.</cmd>
kpriceef160682006-08-29 18:08:31 +000035<info>The root element of an XML file is the element that contains all other
36elements in that file. All of the global elements you have defined in the
37XML schema will be included in the Root element list. If you do not have any
38global elements in your XML schema, you cannot create an XML file from it.</info>
39</step>
40<step><cmd>Select from the following content options:</cmd>
41<choices>
kpriceb59c9f62008-04-02 21:24:37 +000042<choice><uicontrol>Create optional attributes</uicontrol>: both mandatory
kpriceef160682006-08-29 18:08:31 +000043and optional attributes will be generated.</choice>
kpriceb59c9f62008-04-02 21:24:37 +000044<choice><uicontrol>Create optional elements</uicontrol>: both mandatory and
kpriceef160682006-08-29 18:08:31 +000045optional elements will be generated.</choice>
kpriceb59c9f62008-04-02 21:24:37 +000046<choice><uicontrol>Create first choice of required choice</uicontrol>: the
kpriceef160682006-08-29 18:08:31 +000047first option of a required choice will be generated in your XML file.</choice>
kpriceb59c9f62008-04-02 21:24:37 +000048<choice><uicontrol>Fill elements and attributes with data</uicontrol>: any
kpriceef160682006-08-29 18:08:31 +000049elements and attributes generated will be filled with sample data.</choice>
50</choices>
51<info>If you do not select any of these options, then only the minimum amount
52of content required for the XML file will be created.</info></step>
kpriceb59c9f62008-04-02 21:24:37 +000053<step><cmd>The Namespace Information section contains information about the
54target namespace of the XML schema, its prefix, and the schema location. Select
55the entry you want to edit and click <uicontrol>Edit</uicontrol>.</cmd><info><ul>
56<li>The value in the <uicontrol>Namespace Name</uicontrol> field is the target
57namespace of the XML schema. Your XML file should be associated with the same
58namespace as its XML schema is associated with.</li>
59<li>All qualified elements and attributes in the XML file associated with
60the namespace will be prefixed with the <uicontrol>Prefix</uicontrol> value.</li>
61<li>The <uicontrol>Location Hint</uicontrol> field contains the location
62of the XML schema.</li>
63</ul>For more information about namespaces and namespace prefixes, refer to
64the related references.</info></step>
65<step><cmd>Click <uicontrol>OK</uicontrol> and then <uicontrol>Finish</uicontrol>.</cmd>
kpriceef160682006-08-29 18:08:31 +000066</step>
67</steps>
68<result><p>The XML file will contain the selected root element and any elements
69or attributes contained in the root element. It also contains information
70about the XML file namespace and location. You can now add elements and attributes
kpriceb59c9f62008-04-02 21:24:37 +000071to the XML file.</p><note>In certain cases, when an XML file is generated
72from a complex XML schema file, the XML file might not be valid. If this occurs,
73you can open the generated file in the XML editor and correct any errors that
74occur. Usually, only a few errors need to be fixed. The following XML schema
75constructs might present problems:</note><ul><?Pub Caret?>
76<li>Restrictions: sometimes restricted elements are erroneously generated. </li>
77<li>Facets: default generated data values might not conform to complex facets
kpriceef160682006-08-29 18:08:31 +000078(for example, patterns).</li>
kpriceb59c9f62008-04-02 21:24:37 +000079<li>Abstract elements: abstract elements are sometimes erroneously generated.</li>
80</ul></result>
kpriceef160682006-08-29 18:08:31 +000081</taskbody>
82</task>
kpriceb59c9f62008-04-02 21:24:37 +000083<?Pub *0000004762?>