blob: d388f17a309eba2c5153ee9ff24496e3c4059fae [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--Arbortext, Inc., 1988-2005, v.4002-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<!-- /*******************************************************************************
* Copyright (c) 2000, 2005 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/ -->
<link href="../../org.eclipse.wst.doc.user/common.css" rel="stylesheet" type="text/css"/>
<title>Adding a global element</title>
</head>
<body id="taddglem"><a name="taddglem"><!-- --></a> <h1 class="topictitle1">Adding
global elements</h1> <div><p>A global element is an element with a global
scope. It is one that has been declared as part of the main schema rather
than as part of a content model.</p><div class="skipspace"><p>The following
instructions were written for the Resource perspective, but they will also
work in many other perspectives.</p> <p>To add a global 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>Elements</b> section
and click <b> <span class="uicontrol">Add Element</span></b>.</span></li>
<li class="skipspace"><span>In the Properties view, click the <b> <span class="uicontrol">General</span></b> tab,
and type a new name for the global element in the <b> <span class="uicontrol">Name</span></b> field.</span></li>
<li class="skipspace"><span>Specify its type information by clicking the <b> <span
class="uicontrol">Browse</span></b> button <img border="0" height="18" src="../images/Browse.gif"
width="22"/> and selecting the appropriate type.</span> The Set Type dialog
lists all built-in and user-defined types currently available. You can change
the <b> <span class="uicontrol">Scope</span></b> of the list by selecting
one of the following options:<ul>
<li><b><span class="uicontrol">Workspace</span></b>. Lists all of the types
available in your workspace. </li>
<li><b><span class="uicontrol">Enclosing Project</span>.</b> Lists all of
the types available in the project that contains your file. </li>
<li>(Default) <b> <span class="uicontrol">Current Resource</span>.</b> List
all of the types available in your current file.</li>
</ul> </li>
<li class="skipspace"> <div> (Optional) Click the <b><span class="uicontrol">Other</span></b> tab.&nbsp;
In this page, you can specify the following various values for the global
element: <ul>
<li><b><span class="uicontrol">abstract</span></b>. Click <strong>true </strong>if
you want the global element to be abstract. When a global element is declared
to be abstract, it cannot be used in an instance document. Instead, a member
of that global element's substitution group must appear in the instance
document. </li>
<li><b><span class="uicontrol">block</span></b>. This field determines
whether the global element may be replaced by an element derived from it. </li>
<li><b><span class="uicontrol">final</span></b>. This field determines
whether this global element may be derived from. </li>
<li><b><span class="uicontrol">fixed/default</span>.</b> Click the <b> <span
class="uicontrol">Browse</span></b> button <img border="0" height="18" src="../images/Browse.gif"
width="22"/> and select the <b><span class="uicontrol">Fixed</span></b> or <b>
<span class="uicontrol">Default</span></b> radio button and specify an
appropriate value. If you select <strong>Fixed</strong>, the global element
has a fixed value, which cannot be changed. If you select <strong>Default</strong>,
the element has a default value. </li>
<li><b><span class="uicontrol">form</span></b>. Use this field to indicate
if the appearance of this global element in an instance of the XML schema
(that is, an XML file associated with the XML schema) must be qualified
by a namespace. </li>
<li><b><span class="uicontrol">nillable</span></b>. Select <strong>true</strong>
if you do not want the global element to be able to have any child elements,
only attributes. </li>
<li><b><span class="uicontrol">substitutionGroup</span></b>. A substitution
group allows elements to be substituted for other elements.</li>
</ul> </div> &nbsp;</li>
<li class="skipspace"><span>Click the <b> <span class="uicontrol">Attributes</span></b> tab.</span> You
can use this page to add attributes, attribute references, attributes group
references, and <samp class="codeph">any</samp> attributes to your global
element.</li>
<li class="skipspace"><span>An attribute associates an attribute name with
a specific type and value. To add an attribute, right-click in the Attributes
page, and click <span class="uicontrol">Add Attribute</span>.</span> You can
specify the following values for an attribute<ul>
<li><b><span class="uicontrol">fixed/default</span></b>. Click the <span class="uicontrol">Browse</span> button
and select the <b> <span class="uicontrol">Fixed</span></b> or <b> <span class="uicontrol">Default</span></b> radio
button and specify an appropriate value. If you select <b>Fixed</b>, the attribute
has a fixed value, which cannot be changed. If you select <b>Default</b>,
the attribute has a default value.</li>
<li><b><span class="uicontrol">form</span></b>. Use this field to indicate
if the appearance of this attribute in an instance of the XML schema must
be qualified by a namespace.</li>
<li><b><span class="uicontrol">name</span></b>. Enter the name of the attribute.</li>
<li><b><span class="uicontrol">type</span></b>. Click the <b> <span class="uicontrol">Browse</span></b> button <img
border="0" height="18" src="../images/Browse.gif" width="22"/> and select
the type of the attribute. </li>
<li><b><span class="uicontrol">use</span></b>. This field indicates how an
attribute may be used in an instance document. If you select <b>optional</b>,
the attribute may appear once, but it does not have to. If you select <b>required</b>,
the attribute must appear once. If you select <b>prohibited</b>, the attribute
must not appear. <b>Note</b>: If you selected the <span class="uicontrol">Default</span> radio
button, you must select <b>optional</b> in this field, otherwise the default
value will not be valid.</li>
</ul> </li>
<li class="skipspace"><span>An attribute reference provides a reference to
a global attribute. To add an attribute reference, right-click in the Attributes
page, and click <b> <span class="uicontrol">Add Attribute Ref</span>.</b></span> A
declaration that references a global attribute enables the referenced attribute
to appear in the instance document in the context of the referencing declaration.
The menu option to add an attribute reference only appears if there are global
attributes defined elsewhere in the document.<ol type="a">
<li><span>Select the reference, then select the global attribute you want
it to reference from the <b> <span class="uicontrol">ref</span></b> drop down
list.</span></li>
</ol> </li>
<li class="skipspace"><span>An attribute group reference provides a reference
to an attribute group. To add an attribute group reference, right-click in
the Attributes page, and click <b> <span class="uicontrol">Add Attribute Group
Ref</span></b>.</span> A declaration that references an attribute group enables
the referenced attribute group to appear in the instance document in the context
of the referencing declaration. The menu option to add an attribute group
reference only appears if there are attribute groups defined elsewhere in
the document.<ol type="a">
<li><span>Select the reference, then select the attribute group you want it
to reference from the <b> <span class="uicontrol">ref</span></b> drop down
list.</span></li>
</ol> </li>
<li class="stepexpand"><span>An <samp class="codeph">any</samp> element enables
element content according to namespaces, and the corresponding <samp class="codeph">any</samp> attribute
element enables attributes to appear in elements. To add an <samp class="codeph">any</samp> attribute,
right-click in the Attributes page and click <b> <span class="uicontrol">Add
Any Attribute</span></b>.</span> You can specify the following values for
an <samp class="codeph">any</samp> attribute:<ul>
<li>For a <strong>namespace</strong> value, you can select <strong>##any</strong> (this
allows any well-formed XML from any namespace), <b>##local </b> (this allows
any well-formed XML that is not declared to be in a namespace, <b>##other </b> (this
allows any well-formed XML that is not from the target namespace of the type
being defined) or <b>##targetNamespace </b> (which is shorthand for the target
namespace of the type being defined). </li>
<li>For a <span class="uicontrol">processContents</span> value, you can select <b>skip</b> (the
XML processor will not validate the attribute content at all), <b>lax</b>(the
XML processor will validate the attribute content as much as it can), or <b>strict </b> (the
XML processor will validate all the attribute content).</li>
</ul> </li>
<li class="skipspace"><span>Click the <b> <span class="uicontrol">Documentation</span></b> tab
if you want to provide any information about this global 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">You can add a content model to a global element,
which is the representation of any data that may be contained inside the global
element. For more information about working with content models, refer to
the related tasks.</div> </div> <div><p><b class="reltaskshd">Related tasks</b><br/> <a
href="../topics/taddcmod.html" title="You can add a content model to an element, global element, a complex type, or a group. A content model is the representation of any data that may be contained inside the element, global element, complex type, or group."
>Adding a content model</a><br/> <a href="../topics/taddelmr.html" title="An element reference provides a reference to a global element. A declaration that references a global element enables the referenced global element to appear in the instance document in the context of the referencing declaration.?"
>Adding an element reference</a><br/> </p> </div> </body>
</html>