| <?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 lang="en-us" xml:lang="en-us"> |
| <head> |
| <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> |
| <meta name="copyright" content="Copyright (c) 2000, 2006 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" /> |
| <meta name="DC.rights.owner" content="(C) Copyright 2000, 2006" /> |
| <meta content="public" name="security" /> |
| <meta content="index,follow" name="Robots" /> |
| <meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' /> |
| <meta content="task" name="DC.Type" /> |
| <meta name="DC.Title" content="Adding simple types" /> |
| <meta name="abstract" content="Simple types are used to create derived datatypes. They provide a set of constraints on the value space (a set of values) and the lexical space (a set of valid literals) of a datatype." /> |
| <meta name="description" content="Simple types are used to create derived datatypes. They provide a set of constraints on the value space (a set of values) and the lexical space (a set of valid literals) of a datatype." /> |
| <meta content="XML schema editor, adding, simple types, XML schema files" name="DC.subject" /> |
| <meta content="XML schema editor, adding, simple types, XML schema files" name="keywords" /> |
| <meta scheme="URI" name="DC.Relation" content="../topics/taddreg.html" /> |
| <meta content="XHTML" name="DC.Format" /> |
| <meta content="taddsmpt" name="DC.Identifier" /> |
| <meta content="en-us" name="DC.Language" /> |
| <link href="../../org.eclipse.wst.doc.user/common.css" type="text/css" rel="stylesheet" /> |
| <title>Adding simple types</title> |
| </head> |
| <body id="taddsmpt"><a name="taddsmpt"><!-- --></a> |
| |
| |
| <h1 class="topictitle1">Adding simple types</h1> |
| |
| |
| |
| |
| <div><p>Simple types are used to create derived datatypes. |
| They provide a set of constraints on the value space (a set of values) and |
| the lexical space (a set of valid literals) of a datatype.</p> |
| |
| <div class="section"><p>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 have a simple type.</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:</p> |
| </div> |
| |
| <ol> |
| <li class="stepexpand"><span>Open your XML schema in the XML schema editor.</span></li> |
| |
| <li class="stepexpand"><span>In the Outline view, right-click <strong>Types</strong>, and click <span class="uicontrol">Add |
| Simple Type</span>.</span></li> |
| |
| <li class="stepexpand"><span>In the Outline view, select the new simple type.</span></li> |
| |
| <li class="stepexpand"><span>In the Properties view, click the <span class="uicontrol">General</span> tab.</span> |
| </li> |
| |
| <li class="stepexpand"><span>Type a new name for the simple type in the <span class="uicontrol">Name</span> field.</span> |
| </li> |
| |
| <li class="stepexpand"><span>You can select the following options from the <span class="uicontrol">Variety</span> 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="stepexpand"><span>If you selected <span class="uicontrol">atomic</span> from the <span class="uicontrol">Variety</span> list, |
| click <span class="uicontrol">Browse</span> <img src="../images/Browse.gif" alt="This graphic is the Browse button" /> next to the <span class="uicontrol">Base type</span> field |
| to specify a base type for the simple type.</span> The Set Type dialog |
| box lists all built-in and user-defined types currently available. You can |
| change the <span class="uicontrol">Scope</span> of the list by selecting one of the |
| following options:<ul> |
| <li><span class="uicontrol">Workspace</span>. Lists all of the types available in |
| your workspace. </li> |
| |
| <li><span class="uicontrol">Enclosing Project</span>. Lists all of the types available |
| in the project that contains your file. </li> |
| |
| <li>(Default) <span class="uicontrol">Current Resource</span>. List all of the types |
| available in your current file.</li> |
| |
| <li><span class="uicontrol">Working Sets</span>. List all the types available within |
| the selected working set.</li> |
| |
| </ul> |
| </li> |
| |
| <li class="stepexpand"><span>If you selected <span class="uicontrol">list</span> from the <span class="uicontrol">Variety</span> list, |
| click <span class="uicontrol">Browse</span> <img src="../images/Browse.gif" alt="This graphic is the Browse button" /> next to the <span class="uicontrol">Item type</span> field |
| to specify a item type for the simple type.</span> The Set Type dialog |
| box lists all built-in and user-defined types currently available. You can |
| change the <span class="uicontrol">Scope</span> of the list by selecting one of the |
| following options:<ul> |
| <li><span class="uicontrol">Workspace</span>. Lists all of the types available in |
| your workspace. </li> |
| |
| <li><span class="uicontrol">Enclosing Project</span>. Lists all of the types available |
| in the project that contains your file. </li> |
| |
| <li>(Default) <span class="uicontrol">Current Resource</span>. List all of the types |
| available in your current file.</li> |
| |
| <li><span class="uicontrol">Working Sets</span>. List all the types available within |
| the selected working set.</li> |
| |
| </ul> |
| </li> |
| |
| <li class="stepexpand"><span>If you selected <span class="uicontrol">union</span> from the <span class="uicontrol">Variety</span> list, |
| click <span class="uicontrol">Browse</span> <img src="../images/Browse.gif" alt="This graphic is the Browse button" /> next to the <span class="uicontrol">Member types</span> field |
| to specify the member types for the simple type.</span> You can select |
| to add both <span class="uicontrol">Built-in simple types</span> and <span class="uicontrol">User-defined |
| simple types</span> to the member types value list. </li> |
| |
| <li class="stepexpand"><span>Click the <span class="uicontrol">Constraints</span> tab.</span> From |
| here you will be able to set specific constraint values including length constraints, |
| enumerations, and patterns. |
| <ol type="a"> |
| <li class="substepexpand"><span>Enumerations help you to define a set of valid values for simple |
| types. They 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:</span> <ul> |
| <li>To add one enumeration at a time, under <span class="uicontrol">Specific constraint |
| values</span>, select <span class="uicontrol">Enumerations</span> and click <span class="uicontrol">Add</span> and |
| specify a value for the enumeration.</li> |
| |
| <li>To add several enumerations at one time, follow these steps:<ol type="i"> |
| <li>Select <span class="uicontrol">Enumerations</span>.</li> |
| |
| <li>Click <span class="uicontrol">Add</span>.</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 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 entering the value.</li> |
| |
| <li>Click <span class="uicontrol">OK</span>. Your enumerations will be created and |
| appear in the Properties view.</li> |
| |
| </ol> |
| </li> |
| |
| </ul> |
| </li> |
| |
| <li class="substepexpand"><span>Patterns help you to place certain constraints regarding allowable |
| values.</span> For example, you could restrict the field to only accept |
| input which follows the pattern "five digits followed by two upper-case ASCII |
| letters". To set a pattern constraint:<ol type="i"> |
| <li>Select <span class="uicontrol">Patterns</span>.</li> |
| |
| <li>Click <span class="uicontrol">Add</span>.</li> |
| |
| <li>Create the regular expression pattern you wish to use as your constraint |
| using the <span class="uicontrol">Regular Expression</span> wizard.</li> |
| |
| <li>Click <span class="uicontrol">Finish</span>.</li> |
| |
| </ol> |
| </li> |
| |
| </ol> |
| |
| </li> |
| |
| <li class="stepexpand"><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.</li> |
| |
| <li class="stepexpand"><span>Click the <span class="uicontrol">Extensions</span> tab if you want to |
| add application information elements to your annotations of schema components.</span> |
| The <span class="uicontrol">Extensions</span> page allows you to specify the |
| schema and add XML content to your annotations.</li> |
| |
| </ol> |
| |
| </div> |
| |
| <div><div class="reltasks"><strong>Related tasks</strong><br /> |
| <div><a href="../topics/taddreg.html" title="A pattern facet 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.">Adding pattern facets to simple types</a></div> |
| </div> |
| </div> |
| |
| </body> |
| </html> |