blob: cd29f158569663e0eef461f01dddf68f2b31b981 [file] [log] [blame]
<?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">
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../com.ibm.help.doc/swg_info_common.css" />
<title>Adding an import element</title>
<script language="JavaScript">
function popup_window( url, id, width, height )
{
popup = window.open( url, id, 'toolbar=no,scrollbars=no,location=no,statusbar=no,menubar=no,resizable=no,width=' + width + ',height=' + height + ',left=,top=' );
popup.focus();
}
</script><script language="JavaScript" src="help/liveHelp.js"></script></head>
<body id="taddimpt"><a name="taddimpt"><!-- --></a>
<h1 class="topictitle1">Adding an import element</h1>
<div><p>As schemas become larger, it is often desirable to divide their
content among several schema documents for purposes such as ease of maintenance,
reuse, and readability. XML schema defines two constructs to support this: <i>include</i> and <i>import</i>.
The include element brings in definitions and declarations from the included
schema into the current schema. It requires the included schema to be in the
same target namespace as the including schema. The import element behaves
in a similar way, with the exception that the imported schema can come from
a different namespace.</p><div class="skipspace"><p>In the XML schema editor, you can add an import element to an
XML schema. Before you can do this, you must create an XML schema and open
it in the XML schema editor (you can open an XML schema in the XML schema
editor by double-clicking it).</p>
<p>You can add multiple import elements
to an XML schema, however, prefixes and namespaces have to unique amongst
the imported schemas.</p>
<p>An import element is always added to the top of
the schema file, as it must appear as the first children of the schema element. </p>
<p>The
following instructions were written for the Resource perspective, but they
will also work in many other perspectives. </p>
<p>To add an import element,
follow these steps:</p>
</div>
<ol><li class="skipspace"><span>Open your XML schema in the XML schema editor.</span></li>
<li class="skipspace"><span>In the Outline view, select your schema.</span> The entire
schema and its contents should be displayed in the Graph view.</li>
<li class="skipspace"><span>In the Graph view, right click in the <b>Directives</b> section
and click <span class="uicontrol">Add Import</span>.</span></li>
<li class="skipspace"><span>In the Properties view, click the <b>General</b> tab and click
the <span class="uicontrol">More</span> button to the right of the <span class="uicontrol">Schema
location</span> field.</span></li>
<li class="skipspace"><span>If you want to import an XML schema located in the workbench, select
the <span class="uicontrol">Workbench projects</span> radio button and click <span class="uicontrol">Next</span>. </span><ol type="a"><li><span>Select the schema you want to import and click <span class="uicontrol">Finish</span>.</span></li>
</ol>
</li>
<li class="skipspace"><span>If you want to import an XML schema located on the Web, select
the <span class="uicontrol">HTTP</span> radio button and click <span class="uicontrol">Next</span>.</span><ol type="a"><li class="skipspace"><span>Type the URL of the XML schema and click <span class="uicontrol">Finish</span>.</span> <div class="note"><span class="notetitle">Note: </span>A local copy of the schema will not be stored in the workbench.
Every time you validate your schema, the schema's contents will be checked
from the URL you specify.</div>
</li>
</ol>
</li>
<li class="skipspace"><span>The XML schema editor will retrieve the namespace for the imported
XML schema file and display it as read-only in the <span class="uicontrol">Namespace</span> field.</span></li>
<li class="skipspace"><span>If necessary, type a unique prefix for this namespace in the <span class="uicontrol">Prefix</span> field.</span></li>
<li class="skipspace"><span>Click the <span class="uicontrol">Documentation</span> tab if you want
to provide any information about this import element.</span> The <span class="uicontrol">Documentation</span> page
is used for human readable material, such as a description, and the <span class="uicontrol">App
Info</span> page can be used to provide information for applications. </li>
</ol>
<div class="skipspace"><p>Once you have added an import element to your XML schema, when
you define new elements, attributes, complex types, or simple types where
you can specify type information, any declarations from the included schema
will be available in the <span class="uicontrol">Type</span> list for the element,
attribute, complex or simple type.</p>
</div>
<div class="skipspace"></div>
</div>
<div><p><b class="reltaskshd">Related tasks</b><br />
<a href="../topics/taddincl.html" title="As schemas become larger, it is often desirable to divide their content among several schema documents for purposes such as ease of maintenance, reuse, and readability. XML schema defines two constructs to support this: include and import. The include element brings in definitions and declarations from the included schema into the current schema. It requires the included schema to be in the same target namespace as the including schema. The import element behaves in a similar way, with the exception that the imported schema can come from a different namespace.">Adding an include element</a><br />
<a href="../topics/taddrdfn.html" title="You can use the redefine mechanism to redefine simple and complex types, groups, and attribute groups obtained from external schema files. Like the include mechanism, redefine requires the external components to be in the same target namespace as the redefining schema, although external components from schemas that have no namespace can also be redefined.">Adding a redefine element</a><br />
</p>
<p><b class="relrefhd">Related reference</b><br />
<a href="../topics/rnmspc.html" title="">XML namespaces</a><br />
</p>
</div><p>
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.
</p>
</body>
</html>