blob: 46b5ef523e53bd03ff86c5645bb8197f7e7dc727 [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="../../org.eclipse.wst.doc.user/common.css" />
<title>Adding a simple type</title>
</head>
<body id="taddsmpt"><a name="taddsmpt"><!-- --></a>
<h1 class="topictitle1">Adding a simple type</h1>
<div><p>In the XML schema editor, you can add a simple type to an XML schema.
A simple type cannot have element content and cannot carry attributes. Elements
that contain numbers (and strings, and dates, and so on) but do not contain
any sub-elements are said to have simple types. </p><div class="skipspace"><p></p>
<p>The following instructions were written for the Resource
perspective, but they will also work in many other perspectives. </p>
<p>To
add a simple type, 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>Types</b> section and
click <span class="uicontrol">Add Simple Type</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 simple type in the <span class="uicontrol">Name</span> field.</span></li>
<li class="skipspace"><span>You can select the following options from the <span class="uicontrol">Variety</span> drop
down list:</span><ul><li><span class="uicontrol">atomic</span> - atomic types are all the simple types
built into the XML schema language</li>
<li><span class="uicontrol">list</span> - list types are comprised of sequences
of atomic types. They have values that are comprised of finite-length sequences
of atomic values.  </li>
<li><span class="uicontrol">union</span> - a union type enables an element or
attribute value to be one or more instances of one type drawn from the union
of multiple atomic and list types</li>
</ul>
</li>
<li class="skipspace"><span>If you selected <span class="uicontrol">atomic</span> from the <span class="uicontrol">Variety</span> drop
down list, click the <span class="uicontrol">More</span> button next to the <span class="uicontrol">Base
type</span> field to specify a base type for the simple type.</span> You
can select either a <span class="uicontrol">Built-in simple type</span>, or <span class="uicontrol">User-defined
simple type</span> to be the base type.</li>
<li class="skipspace"><span>If you selected <span class="uicontrol">list</span> from the <span class="uicontrol">Variety</span> drop
down list, click the <span class="uicontrol">More</span> button next to the <span class="uicontrol">Item
type</span> field to specify a item type for the simple type.</span> You
can select either a <span class="uicontrol">Built-in simple type</span>, or <span class="uicontrol">User-defined
simple type</span> to be the item type.</li>
<li class="skipspace"><span>If you selected <span class="uicontrol">union</span> from the <span class="uicontrol">Variety</span> drop
down list, click the <span class="uicontrol">More</span> button next to the <span class="uicontrol">Member
types</span> field to specify the member types for the simple type.</span> You can select both <span class="uicontrol">Built-in simple type</span>, or <span class="uicontrol">User-defined
simple type</span> to add to the member types list.</li>
<li class="skipspace"><span>Click the <span class="uicontrol">Enumerations</span> tab.</span> Enumerations
help you to define a set of valid values for simple types. Enumerations are
the actual values the simple type can take as valid values in the instance
document. You can either add one enumeration or several enumerations at a
time:<ol type="a"><li class="skipspace"><span>To add one enumeration at a time, click the <span class="uicontrol">Add</span> button
and specify a value for the enumeration.</span></li>
<li class="skipspace"><span>To add several enumerations at one time, follow these steps:</span> <ol><li>Click the <span class="uicontrol">Add...</span> button.</li>
<li>Enter the value of each enumeration. Each value must be separated by the <span class="uicontrol">Delimiter
character</span>. For example: <samp class="codeph">First, Second</samp> will create
two enumerations, one with the value "First" and one with the value "Second".</li>
<li>Select the <span class="uicontrol">Preserve leading and trailing whitespace</span> check
box if you want any white space around your enumeration values to be preserved.
If, for example, you select this check box, the values of <samp class="codeph">First, Second</samp> will
show up as "First" and " Second" (there is a space before Second) because
you put a space before "Second" when entered the value.</li>
<li>Click <span class="uicontrol">OK</span>. Your enumerations will be created and
appear in the Properties view.</li>
</ol>
</li>
</ol>
</li>
<li class="skipspace"><span>Click the <span class="uicontrol">Documentation</span> tab if you want
to provide any information about this simple type.</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>
<li class="skipspace"><span>Click the <span class="uicontrol">Advanced</span> tab.</span> The options
available from this page will vary depending on what option you selected in
the <span class="uicontrol">Variety</span> field, and the <span class="uicontrol">Base type</span>, <span class="uicontrol">Item
type</span>, or <span class="uicontrol">Member types</span> field on the <span class="uicontrol">General</span> page.</li>
<li class="skipspace"><span>If applicable to the type, the <span class="uicontrol">Facets</span> table
will be populated with constraining facets. A constraining facet is an optional
property that can be applied to a datatype to constrain its value.</span><ol type="a"><li><span>To change a facet's value, click its name in the <span class="uicontrol">Name</span> column,
then click its value (or the empty cell that will contain its value) in the <span class="uicontrol">Value</span> column
and type or select a new value</span></li>
<li><span> To change whether a facet's value is fixed or not, click its
name in the Name column, then click the appropriate cell in the Fixed column,
and change the value to true or false.</span></li>
</ol>
</li>
<li class="skipspace"><span>If applicable to the type, a Pattern page will be
available. Click the <span class="uicontrol">Pattern</span> tab to switch to it.</span> A pattern can be used to constrain the value of a type's lexical space
(the set of string literals that represent the values of a type), which indirectly
constrains the value space. For more information on adding a pattern to a
simple type, refer to the related tasks.</li>
</ol>
</div>
<p>
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.
</p>
</body>
</html>