blob: 7449eb01fab9562804ed797ac61c87398c0e2f94 [file] [log] [blame]
kprice159fa582006-05-08 21:30:45 +00001<?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">
syeshind0bdb8e2005-10-27 17:44:14 +00002<html lang="en-us" xml:lang="en-us">
syeshinf3d0d4b2005-07-27 18:33:03 +00003<head>
kprice159fa582006-05-08 21:30:45 +00004<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
kpricede20a692008-04-24 00:27:47 +00005<meta name="copyright" content="Copyright (c) 2000, 2008 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" />
6<meta name="DC.rights.owner" content="(C) Copyright 2000, 2008" />
kprice159fa582006-05-08 21:30:45 +00007<meta content="public" name="security" />
8<meta content="index,follow" name="Robots" />
9<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))' />
10<meta content="task" name="DC.Type" />
11<meta name="DC.Title" content="Adding simple types" />
kprice43d0c0f2006-05-18 15:56:09 +000012<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." />
13<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." />
kpricede20a692008-04-24 00:27:47 +000014<meta content="XML schema editor, simple types, XML schema files" name="DC.subject" />
15<meta content="XML schema editor, simple types, XML schema files" name="keywords" />
kprice43d0c0f2006-05-18 15:56:09 +000016<meta scheme="URI" name="DC.Relation" content="../topics/taddreg.html" />
kprice159fa582006-05-08 21:30:45 +000017<meta content="XHTML" name="DC.Format" />
18<meta content="taddsmpt" name="DC.Identifier" />
19<meta content="en-us" name="DC.Language" />
20<link href="../../org.eclipse.wst.doc.user/common.css" type="text/css" rel="stylesheet" />
syeshind0bdb8e2005-10-27 17:44:14 +000021<title>Adding simple types</title>
syeshin8f077832005-09-06 04:22:45 +000022</head>
kprice159fa582006-05-08 21:30:45 +000023<body id="taddsmpt"><a name="taddsmpt"><!-- --></a>
24
25
26<h1 class="topictitle1">Adding simple types</h1>
27
28
29
30
kpricede20a692008-04-24 00:27:47 +000031<div><p>Simple types are used to create derived datatypes. They provide
32a set of constraints on the value space (a set of values) and the lexical
33space (a set of valid literals) of a datatype.</p>
kprice159fa582006-05-08 21:30:45 +000034
35<div class="section"><p>A simple type cannot have element content and cannot carry attributes.
36Elements that contain numbers (and strings, and dates, and so on) but do not
kprice43d0c0f2006-05-18 15:56:09 +000037contain any sub-elements have a simple type.</p>
38<p>The following instructions
39were written for the Resource perspective, but they will also work in many
40other perspectives.</p>
kpricede20a692008-04-24 00:27:47 +000041<p>To add a simple type, complete the following steps:</p>
kprice159fa582006-05-08 21:30:45 +000042</div>
43
44<ol>
lmandel79573072006-03-30 03:29:16 +000045<li class="stepexpand"><span>Open your XML schema in the XML schema editor.</span></li>
kprice159fa582006-05-08 21:30:45 +000046
47<li class="stepexpand"><span>In the Outline view, right-click <strong>Types</strong>, and click <span class="uicontrol">Add
48Simple Type</span>.</span></li>
49
kprice43d0c0f2006-05-18 15:56:09 +000050<li class="stepexpand"><span>In the Outline view, select the new simple type.</span></li>
51
52<li class="stepexpand"><span>In the Properties view, click the <span class="uicontrol">General</span> tab.</span>
53</li>
54
55<li class="stepexpand"><span>Type a new name for the simple type in the <span class="uicontrol">Name</span> field.</span>
56</li>
kprice159fa582006-05-08 21:30:45 +000057
58<li class="stepexpand"><span>You can select the following options from the <span class="uicontrol">Variety</span> list:</span>
59<ul>
kpricede20a692008-04-24 00:27:47 +000060<li><span class="uicontrol">atomic</span>: atomic types are all the
61simple types built into the XML schema language.</li>
kprice159fa582006-05-08 21:30:45 +000062
kpricede20a692008-04-24 00:27:47 +000063<li><span class="uicontrol">list</span>: list types are comprised of sequences
kprice159fa582006-05-08 21:30:45 +000064of atomic types. They have values that are comprised of finite-length sequences
65of atomic values. </li>
66
kpricede20a692008-04-24 00:27:47 +000067<li><span class="uicontrol">union</span>: union types enable an element or attribute
kprice159fa582006-05-08 21:30:45 +000068value to be one or more instances of one type drawn from the union of multiple
69atomic and list types.</li>
70
71</ul>
72
73</li>
74
kpricede20a692008-04-24 00:27:47 +000075<li class="stepexpand"><span>If you selected <span class="uicontrol">atomic</span> or <span class="uicontrol">list</span> from
76the <span class="uicontrol">Variety</span> drop-down, click <span class="uicontrol">Browse</span> <img src="../images/Browse.gif" alt="This graphic is the Browse button" /> next
77to the <span class="uicontrol">Base type</span> or <span class="uicontrol">Item type</span> field
kprice43d0c0f2006-05-18 15:56:09 +000078to specify a base type for the simple type.</span> The Set Type dialog
79box lists all built-in and user-defined types currently available. You can
80change the <span class="uicontrol">Scope</span> of the list by selecting one of the
81following options:<ul>
kpricede20a692008-04-24 00:27:47 +000082<li><span class="uicontrol">Workspace</span>: lists all of the types available in
kprice159fa582006-05-08 21:30:45 +000083your workspace. </li>
84
kpricede20a692008-04-24 00:27:47 +000085<li><span class="uicontrol">Enclosing Project</span>: lists all of the types available
kprice159fa582006-05-08 21:30:45 +000086in the project that contains your file. </li>
87
kpricede20a692008-04-24 00:27:47 +000088<li>(Default) <span class="uicontrol">Current Resource</span>: lists all of the types
kprice159fa582006-05-08 21:30:45 +000089available in your current file.</li>
90
kpricede20a692008-04-24 00:27:47 +000091<li><span class="uicontrol">Working Sets</span>: lists all the types available within
kprice159fa582006-05-08 21:30:45 +000092the selected working set.</li>
93
94</ul>
95</li>
96
kpricede20a692008-04-24 00:27:47 +000097<li class="stepexpand"><span>If you selected <span class="uicontrol">union</span> from the <span class="uicontrol">Variety</span> drop-down,
kprice43d0c0f2006-05-18 15:56:09 +000098click <span class="uicontrol">Browse</span> <img src="../images/Browse.gif" alt="This&#10;graphic is the Browse button" /> next to the <span class="uicontrol">Member types</span> field
99to specify the member types for the simple type.</span> You can select
100to add both <span class="uicontrol">Built-in simple types</span> and <span class="uicontrol">User-defined
kprice159fa582006-05-08 21:30:45 +0000101simple types</span> to the member types value list. </li>
102
103<li class="stepexpand"><span>Click the <span class="uicontrol">Constraints</span> tab.</span> From
104here you will be able to set specific constraint values including length constraints,
105enumerations, and patterns.
106<ol type="a">
107<li class="substepexpand"><span>Enumerations help you to define a set of valid values for simple
108types. They are the actual values the simple type can take as valid values
109in the instance document. You can either add one enumeration or several enumerations
110at a time:</span> <ul>
111<li>To add one enumeration at a time, under <span class="uicontrol">Specific constraint
kprice43d0c0f2006-05-18 15:56:09 +0000112values</span>, select <span class="uicontrol">Enumerations</span> and click <span class="uicontrol">Add</span> and
113specify a value for the enumeration.</li>
kprice159fa582006-05-08 21:30:45 +0000114
kpricede20a692008-04-24 00:27:47 +0000115<li>To add several enumerations at one time:<ol type="i">
116<li>Select <span class="uicontrol">Enumerations</span> and click <span class="uicontrol">Add</span>.</li>
kprice159fa582006-05-08 21:30:45 +0000117
118<li>Enter the value of each enumeration. Each value must be separated by the <span class="uicontrol">Delimiter
119character</span>. For example: <samp class="codeph">First, Second</samp> will create
120two enumerations, one with the value "First" and one with the value "Second".</li>
121
122<li>Select the <span class="uicontrol">Preserve leading and trailing whitespace</span> check
syeshinf3d0d4b2005-07-27 18:33:03 +0000123box if you want any white space around your enumeration values to be preserved.
kprice43d0c0f2006-05-18 15:56:09 +0000124If you select this check box, the values of <samp class="codeph">First, Second</samp> will
kprice159fa582006-05-08 21:30:45 +0000125show up as "First" and " Second" (there is a space before Second) because
kprice43d0c0f2006-05-18 15:56:09 +0000126you put a space before "Second" when entering the value.</li>
kprice159fa582006-05-08 21:30:45 +0000127
128<li>Click <span class="uicontrol">OK</span>. Your enumerations will be created and
129appear in the Properties view.</li>
130
131</ol>
132</li>
133
134</ul>
135</li>
136
137<li class="substepexpand"><span>Patterns help you to place certain constraints regarding allowable
138values.</span> For example, you could restrict the field to only accept
139input which follows the pattern "five digits followed by two upper-case ASCII
140letters". To set a pattern constraint:<ol type="i">
kpricede20a692008-04-24 00:27:47 +0000141<li>Select <span class="uicontrol">Patterns</span> and click <span class="uicontrol">Add</span>.</li>
kprice159fa582006-05-08 21:30:45 +0000142
143<li>Create the regular expression pattern you wish to use as your constraint
144using the <span class="uicontrol">Regular Expression</span> wizard.</li>
145
146<li>Click <span class="uicontrol">Finish</span>.</li>
147
148</ol>
149</li>
150
151</ol>
152
153</li>
154
155<li class="stepexpand"><span>Click the <span class="uicontrol">Documentation</span> tab if you want
156to provide any information about this simple type.</span> The <span class="uicontrol">Documentation</span> page
kprice43d0c0f2006-05-18 15:56:09 +0000157is used for human readable material, such as a description.</li>
158
159<li class="stepexpand"><span>Click the <span class="uicontrol">Extensions</span> tab if you want to
160add application information elements to your annotations of schema components.</span>
161 The <span class="uicontrol">Extensions</span> page allows you to specify the
162schema and add XML content to your annotations.</li>
kprice159fa582006-05-08 21:30:45 +0000163
164</ol>
165
166</div>
167
kprice43d0c0f2006-05-18 15:56:09 +0000168<div><div class="reltasks"><strong>Related tasks</strong><br />
169<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>
170</div>
171</div>
kprice159fa582006-05-08 21:30:45 +0000172
173</body>
174</html>