blob: 9cbabc13358ff14504705b3e6052162400d1c299 [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 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="taddelm"><a name="taddelm"><!-- --></a>
<h1 class="topictitle1">Adding an element</h1>
<div><p>Elements are fundamental building blocks in XML - they consist
of a start-tag, and end-tag, and any text that is contained between the two.</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 an
element, follow these steps:</p>
</div>
<ol><li class="skipspace"><span>In the Outline view, right-click the content model you want to
work with and click <span class="uicontrol">Add Element</span>.</span></li>
<li class="skipspace"><span>In the Properties view, type a new name for the element in the <span class="uicontrol">Name</span> field.</span></li>
<li class="skipspace"><span>Specify its type information by clicking the <span class="uicontrol">More</span> button
and selecting the appropriate type.</span> An element type can reference
a complex type or a simple type. An element or attribute can define its type
to be anonymous. You do not have to name an anonymous type since an anonymous
type cannot be referenced directly. To specify that a global element's type
is anonymous, when the <span class="uicontrol">User-defined simple type</span> or <span class="uicontrol">User-defined
complex type</span> radio button is selected ,click <span class="uicontrol">**anonymous**</span> in
the type list. </li>
<li class="skipspace"><span>(Optional) Select the appropriate value in the <span class="uicontrol">MinOccurs</span> field.</span> This is the number of times the element may appear. If you want the
element to be optional, select <span class="uicontrol">0</span>. Otherwise, select <span class="uicontrol">1</span>. </li>
<li class="skipspace"><span>(Optional) Select the appropriate value in the <span class="uicontrol">MaxOccurs</span> field.</span> This is the maximum number of times the element may appear. You can
select <span class="uicontrol">unbounded</span> to indicate there is no maximum number
of occurrences.</li>
<li class="skipspace"><span>(Optional) Click the <span class="uicontrol">Other</span> tab. </span> In this page, you can specify various values for the element, such as
, <span class="uicontrol">block</span>, <span class="uicontrol">fixed/default</span>,<span class="uicontrol">form</span>and <span class="uicontrol">nillable</span>.</li>
<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 <span class="uicontrol">Add Element</span>.</span></li>
<li class="skipspace"><span>In the Properties view, click the <span class="uicontrol">General</span> tab,
and type a new name for the global element in the <span class="uicontrol">Name</span> field.</span></li>
<li class="skipspace"><span>Specify its type information by clicking the <span class="uicontrol">More</span> button
and selecting the appropriate type.</span> An element type can reference
a complex type or a simple type. An element or attribute can define its type
to be anonymous. You do not have to name an anonymous type since an anonymous
type cannot be referenced directly. To specify that a global element's type
is anonymous, when the <span class="uicontrol">User-defined simple type</span> or <span class="uicontrol">User-defined
complex type</span> radio button is selected ,click <span class="uicontrol">**anonymous**</span> in
the type list. </li>
<li class="skipspace"><span>(Optional) Click the <span class="uicontrol">Other</span> tab. </span> In this page, you can specify various values for the global element,
such as <span class="uicontrol">abstract</span>, <span class="uicontrol">block</span>, <span class="uicontrol">final</span>, <span class="uicontrol">fixed/default</span>, <span class="uicontrol">nillable</span>, and <span class="uicontrol">substituionGroup</span>.</li>
<li class="skipspace"><span>Click the <span class="uicontrol">Attributes</span> 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><span class="uicontrol">fixed/default</span>.Click the <span class="uicontrol">More</span> button
and select the <span class="uicontrol">Fixed</span> or <span class="uicontrol">Default</span> 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><span class="uicontrol">form</span>. 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><span class="uicontrol">name</span>. Enter the name of the attribute.</li>
<li><span class="uicontrol">type</span>. Click the <span class="uicontrol">More</span> button
and select the type of the attribute. </li>
<li><span class="uicontrol">use</span>. 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 <span class="uicontrol">Add
Attribute Ref</span>.</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<span class="uicontrol">ref</span> 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 <span class="uicontrol">Add Attribute Group Ref</span>.</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<span class="uicontrol">ref</span> drop down list.</span></li>
</ol>
</li>
<li class="skipspace"><span>An <samp class="codeph">any</samp> element enables attributes to appear
in <samp class="codeph">any</samp> elements. To add an <samp class="codeph">any</samp> attribute,
right-click in the Attributes page, and click <span class="uicontrol">Add Any Attribute</span>.</span> You can specify the following values for an <samp class="codeph">any</samp> attribute:<ul><li>For a <b>namespace</b> value, you can select <b>##any</b> (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 <span class="uicontrol">Documentation</span> tab if you want
to provide any information about this 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 an element, which is the representation
of any data that may be contained inside the 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 />
</p>
</div><p>
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.
</p>
</body>
</html>