| <?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> |
| <!-- /******************************************************************************* |
| * 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 rel="stylesheet" type="text/css" href="../../org.eclipse.wst.doc.user/common.css" /> |
| <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 created derived datatypes. They provide |
| a set of constraints on the value space (that is, a set of values) and the |
| lexical space (that is, 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 are said to 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, follow these |
| steps:</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, select your schema.</span> The entire |
| schema and its contents should be displayed in the Graph view.</li> |
| <li class="stepexpand"><span>In the Graph view, right-click in the <strong>Types</strong> section and |
| click <b> <span class="uicontrol">Add Simple Type</span></b>.</span></li> |
| <li class="stepexpand"><span>In the Properties view, click the <span class="uicontrol">General</span> tab, |
| and type a new name for the simple type in the <b> <span class="uicontrol">Name</span></b> field.</span></li> |
| <li class="stepexpand"><span>You can select the following options from the <b> <span class="uicontrol">Variety</span></b> list:</span><ul><li> |
| <b><span class="uicontrol">atomic</span></b>. Atomic types are all the simple types |
| built into the XML schema language.</li> |
| <li><b><span class="uicontrol">list</span></b>. List types are comprised of sequences |
| of atomic types. They have values that are comprised of finite-length sequences |
| of atomic values. </li> |
| <li><b><span class="uicontrol">union</span></b>. 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 |
| <b> <span class="uicontrol">Variety</span></b> drop |
| down list, click the <b> <span class="uicontrol">More</span></b> <img src="../images/More.gif" alt="This graphic is the More button" /> button next to the |
| <b> <span class="uicontrol">Base |
| type</span></b> field to specify a base type for the simple 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="stepexpand"><span>If you selected <span class="uicontrol">list</span> from the |
| <b> <span class="uicontrol">Variety</span></b> drop |
| down list, click the <b> <span class="uicontrol">More</span></b> <img src="../images/More.gif" alt="This graphic is the More button" /> button next to the |
| <b> <span class="uicontrol">Item |
| type</span> </b>field to specify a item type for the simple 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="stepexpand"><span>If you selected <span class="uicontrol">union</span> from the |
| <b> <span class="uicontrol">Variety</span></b> drop |
| down list, click the <b> <span class="uicontrol">More</span></b> <img src="../images/More.gif" alt="This graphic is the More button" /> button next to the |
| <b> <span class="uicontrol">Member |
| types</span> </b>field to specify the member types for the simple type.</span> You can select to add both |
| <b> <span class="uicontrol">Built-in simple types</span></b> and <b> <span class="uicontrol">User-defined |
| simple types</span></b> to the member types value list. </li> |
| <li class="stepexpand"><span>Click the <b> <span class="uicontrol">Enumerations</span></b> tab.</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:<ol type="a"><li class="substepexpand"><span>To add one enumeration at a time, click the |
| <b> <span class="uicontrol">Add</span></b> button |
| and specify a value for the enumeration.</span></li> |
| <li class="substepexpand"><span>To add several enumerations at one time, follow these steps:</span> <ol type="i"><li>Click the |
| <b> <span class="uicontrol">Add...</span></b> button.</li> |
| <li>Enter the value of each enumeration. Each value must be separated by the <b> <span class="uicontrol">Delimiter |
| character</span></b>. 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 <b> <span class="uicontrol">Preserve leading and trailing whitespace</span></b> 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 <b> <span class="uicontrol">OK</span></b>. Your enumerations will be created and |
| appear in the Properties view.</li> |
| </ol> |
| </li> |
| </ol> |
| </li> |
| <li class="skipspace"><span>Click the <b> <span class="uicontrol">Documentation</span></b> 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 <b> <span class="uicontrol">Advanced</span></b> tab.</span> The options |
| available from this page will vary depending on what option you selected in |
| the <b> <span class="uicontrol">Variety</span></b> field, and the <b> <span class="uicontrol">Base type</span>,</b> |
| <b> <span class="uicontrol">Item |
| type</span>,</b> or <b> <span class="uicontrol">Member types</span></b> field on the <span class="uicontrol">General</span> page.</li> |
| <li class="skipspace"><span>If applicable to the type, the <b> <span class="uicontrol">Facets</span></b> 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 |
| <b> <span class="uicontrol">Name</span></b> column, |
| then click its value (or the empty cell that will contain its value) in the <b> <span class="uicontrol">Value</span></b> 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 <b>Name</b> column, then click the appropriate cell in the <b>Fixed</b> column, |
| and change the value to true or false.</span></li> |
| </ol> |
| </li> |
| <li class="stepexpand"><span>If applicable to the type, a Pattern page will be available. Click |
| the <b> <span class="uicontrol">Patterns</span></b> 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> |
| <p><b class="reltaskshd">Related tasks</b><br /> |
| <a href="taddreg.html">Adding pattern facets to simple types</a></p> |
| </div> |
| </body> |
| </html> |