blob: 20df2b6ea418c5126b92a661ba94f722c07e8ec6 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--Arbortext, Inc., 1988-2005, v.4002-->
<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<?Pub Inc?>
<task id="tcrexxsd" xml:lang="en-us">
<title>Generating XML files from XML schemas</title>
<titlealts>
<searchtitle>Generating an XML file from an XML schema</searchtitle>
</titlealts>
<shortdesc>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.</shortdesc>
<prolog><metadata>
<keywords><indexterm>XML files<indexterm>generating from XML schemas</indexterm></indexterm>
<indexterm>XML schemas<indexterm>generating XML files</indexterm></indexterm>
</keywords>
</metadata></prolog>
<taskbody>
<context><p>After you have generated your XML file, you can further customize
it in the XML editor.</p><p>The following instructions were written for the
Resource perspective, but they will also work in many other perspectives.</p><p>To
generate an XML file from a schema file follow these steps:</p></context>
<steps>
<step><cmd>In the Navigator view, right-click the XML schema file that you
want to work with.</cmd></step>
<step><cmd>From its pop-up menu click <menucascade><uicontrol>Generate</uicontrol>
<uicontrol>XML File</uicontrol></menucascade>.</cmd></step>
<step><cmd>Select a project or folder to contain the XML file, type a name
for it and click <uicontrol>Next</uicontrol>.</cmd><info>The name of the file
must end in<systemoutput>.xml.</systemoutput> </info></step>
<step><cmd>Click the <uicontrol>Root element</uicontrol> of the XML file.</cmd>
<info>The root element of an XML file is the element that contains all other
elements in that file. All of the global elements you have defined in the
XML schema will be included in the Root element list. If you do not have any
global elements in your XML schema, you cannot create an XML file from it.</info>
</step>
<step><cmd>Select from the following content options:</cmd>
<choices>
<choice><uicontrol>Create optional attributes</uicontrol>. Both mandatory
and optional attributes will be generated.</choice>
<choice><uicontrol>Create optional elements</uicontrol>. Both mandatory and
optional elements will be generated.</choice>
<choice><uicontrol>Create first choice of required choice</uicontrol>. The
first option of a required choice will be generated in your XML file.</choice>
<choice><uicontrol>Fill elements and attributes with data</uicontrol>. Any
elements and attributes generated will be filled with sample data.</choice>
</choices>
<info>If you do not select any of these options, then only the minimum amount
of content required for the XML file will be created.</info></step>
<step><cmd>The Namespace information section contains information about the
target namespace of the XML schema, its prefix, and the schema location.</cmd>
<info>For more information about namespaces and namespace prefixes, refer
to the related references.</info></step>
<step><cmd>Select the entry you want to edit and click <uicontrol>Edit</uicontrol>.</cmd>
</step>
<step><cmd>The value in the <uicontrol>Namespace Name</uicontrol> field is
the target namespace of the XML schema.</cmd><info>Your XML file should be
associated with the same namespace as its XML schema is associated with.</info>
</step>
<step><cmd>All qualified elements and attributes in the XML file associated
with the namespace will be prefixed with the <uicontrol>Prefix</uicontrol> value.</cmd>
</step>
<step><cmd>The <uicontrol>Location Hint</uicontrol> field contains the location
of the XML schema.</cmd></step>
<step><cmd>Click <uicontrol>OK</uicontrol>, then <uicontrol>Finish</uicontrol>.</cmd>
</step>
</steps>
<result><p>The XML file will contain the selected root element and any elements
or attributes contained in the root element. It also contains information
about the XML file namespace and location. You can now add elements and attributes
to the XML file.</p><p><b>Note:</b> In certain cases, when an XML file is
generated from a complex XML schema file, the XML file might not be valid.
If this occurs, you can open the generated file in the XML editor and correct
any errors that occur. Usually, only a few errors need to be fixed. The following
XML schema constructs might present problems:</p><ol>
<li>Restrictions. Sometimes restricted elements are erroneously generated. </li>
<li>Facets: Default generated data values might not conform to complex facets
(for example, patterns).</li>
<li>Abstract elements. abstract elements are sometimes erroneously generated.</li>
</ol></result>
</taskbody>
</task>
<?Pub *0000004757?>