blob: f6991670b31cb3df7c279a39825a33d51d52a626 [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" />
5<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" />
6<meta name="DC.rights.owner" content="(C) Copyright 2000, 2006" />
7<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." />
kprice159fa582006-05-08 21:30:45 +000014<meta content="XML schema editor, adding, simple types, XML schema files" name="DC.subject" />
15<meta content="XML schema editor, adding, 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
kprice43d0c0f2006-05-18 15:56:09 +000031<div><p>Simple types are used to create derived datatypes.
32They provide a set of constraints on the value space (a set of values) and
33the lexical space (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>
41<p>To add a simple type:</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>
60<li><span class="uicontrol">atomic</span>. Atomic types are all the simple types
61built into the XML schema language.</li>
62
63<li><span class="uicontrol">list</span>. List types are comprised of sequences
64of atomic types. They have values that are comprised of finite-length sequences
65of atomic values. </li>
66
67<li><span class="uicontrol">union</span>. A union type enables an element or attribute
68value 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
kprice43d0c0f2006-05-18 15:56:09 +000075<li class="stepexpand"><span>If you selected <span class="uicontrol">atomic</span> from the <span class="uicontrol">Variety</span> list,
76click <span class="uicontrol">Browse</span> <img src="../images/Browse.gif" alt="This&#10;graphic is the Browse button" /> next to the <span class="uicontrol">Base type</span> field
77to specify a base type for the simple type.</span> The Set Type dialog
78box lists all built-in and user-defined types currently available. You can
79change the <span class="uicontrol">Scope</span> of the list by selecting one of the
80following options:<ul>
kprice159fa582006-05-08 21:30:45 +000081<li><span class="uicontrol">Workspace</span>. Lists all of the types available in
82your workspace. </li>
83
84<li><span class="uicontrol">Enclosing Project</span>. Lists all of the types available
85in the project that contains your file. </li>
86
87<li>(Default) <span class="uicontrol">Current Resource</span>. List all of the types
88available in your current file.</li>
89
90<li><span class="uicontrol">Working Sets</span>. List all the types available within
91the selected working set.</li>
92
93</ul>
94</li>
95
kprice43d0c0f2006-05-18 15:56:09 +000096<li class="stepexpand"><span>If you selected <span class="uicontrol">list</span> from the <span class="uicontrol">Variety</span> list,
97click <span class="uicontrol">Browse</span> <img src="../images/Browse.gif" alt="This&#10;graphic is the Browse button" /> next to the <span class="uicontrol">Item type</span> field
98to specify a item type for the simple type.</span> The Set Type dialog
99box lists all built-in and user-defined types currently available. You can
100change the <span class="uicontrol">Scope</span> of the list by selecting one of the
101following options:<ul>
kprice159fa582006-05-08 21:30:45 +0000102<li><span class="uicontrol">Workspace</span>. Lists all of the types available in
103your workspace. </li>
104
105<li><span class="uicontrol">Enclosing Project</span>. Lists all of the types available
106in the project that contains your file. </li>
107
108<li>(Default) <span class="uicontrol">Current Resource</span>. List all of the types
109available in your current file.</li>
110
111<li><span class="uicontrol">Working Sets</span>. List all the types available within
112the selected working set.</li>
113
114</ul>
115</li>
116
kprice43d0c0f2006-05-18 15:56:09 +0000117<li class="stepexpand"><span>If you selected <span class="uicontrol">union</span> from the <span class="uicontrol">Variety</span> list,
118click <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
119to specify the member types for the simple type.</span> You can select
120to add both <span class="uicontrol">Built-in simple types</span> and <span class="uicontrol">User-defined
kprice159fa582006-05-08 21:30:45 +0000121simple types</span> to the member types value list. </li>
122
123<li class="stepexpand"><span>Click the <span class="uicontrol">Constraints</span> tab.</span> From
124here you will be able to set specific constraint values including length constraints,
125enumerations, and patterns.
126<ol type="a">
127<li class="substepexpand"><span>Enumerations help you to define a set of valid values for simple
128types. They are the actual values the simple type can take as valid values
129in the instance document. You can either add one enumeration or several enumerations
130at a time:</span> <ul>
131<li>To add one enumeration at a time, under <span class="uicontrol">Specific constraint
kprice43d0c0f2006-05-18 15:56:09 +0000132values</span>, select <span class="uicontrol">Enumerations</span> and click <span class="uicontrol">Add</span> and
133specify a value for the enumeration.</li>
kprice159fa582006-05-08 21:30:45 +0000134
135<li>To add several enumerations at one time, follow these steps:<ol type="i">
kprice43d0c0f2006-05-18 15:56:09 +0000136<li>Select <span class="uicontrol">Enumerations</span>.</li>
kprice159fa582006-05-08 21:30:45 +0000137
kprice43d0c0f2006-05-18 15:56:09 +0000138<li>Click <span class="uicontrol">Add</span>.</li>
kprice159fa582006-05-08 21:30:45 +0000139
140<li>Enter the value of each enumeration. Each value must be separated by the <span class="uicontrol">Delimiter
141character</span>. For example: <samp class="codeph">First, Second</samp> will create
142two enumerations, one with the value "First" and one with the value "Second".</li>
143
144<li>Select the <span class="uicontrol">Preserve leading and trailing whitespace</span> check
syeshinf3d0d4b2005-07-27 18:33:03 +0000145box if you want any white space around your enumeration values to be preserved.
kprice43d0c0f2006-05-18 15:56:09 +0000146If you select this check box, the values of <samp class="codeph">First, Second</samp> will
kprice159fa582006-05-08 21:30:45 +0000147show up as "First" and " Second" (there is a space before Second) because
kprice43d0c0f2006-05-18 15:56:09 +0000148you put a space before "Second" when entering the value.</li>
kprice159fa582006-05-08 21:30:45 +0000149
150<li>Click <span class="uicontrol">OK</span>. Your enumerations will be created and
151appear in the Properties view.</li>
152
153</ol>
154</li>
155
156</ul>
157</li>
158
159<li class="substepexpand"><span>Patterns help you to place certain constraints regarding allowable
160values.</span> For example, you could restrict the field to only accept
161input which follows the pattern "five digits followed by two upper-case ASCII
162letters". To set a pattern constraint:<ol type="i">
kprice43d0c0f2006-05-18 15:56:09 +0000163<li>Select <span class="uicontrol">Patterns</span>.</li>
kprice159fa582006-05-08 21:30:45 +0000164
kprice43d0c0f2006-05-18 15:56:09 +0000165<li>Click <span class="uicontrol">Add</span>.</li>
kprice159fa582006-05-08 21:30:45 +0000166
167<li>Create the regular expression pattern you wish to use as your constraint
168using the <span class="uicontrol">Regular Expression</span> wizard.</li>
169
170<li>Click <span class="uicontrol">Finish</span>.</li>
171
172</ol>
173</li>
174
175</ol>
176
177</li>
178
179<li class="stepexpand"><span>Click the <span class="uicontrol">Documentation</span> tab if you want
180to provide any information about this simple type.</span> The <span class="uicontrol">Documentation</span> page
kprice43d0c0f2006-05-18 15:56:09 +0000181is used for human readable material, such as a description.</li>
182
183<li class="stepexpand"><span>Click the <span class="uicontrol">Extensions</span> tab if you want to
184add application information elements to your annotations of schema components.</span>
185 The <span class="uicontrol">Extensions</span> page allows you to specify the
186schema and add XML content to your annotations.</li>
kprice159fa582006-05-08 21:30:45 +0000187
188</ol>
189
190</div>
191
kprice43d0c0f2006-05-18 15:56:09 +0000192<div><div class="reltasks"><strong>Related tasks</strong><br />
193<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>
194</div>
195</div>
kprice159fa582006-05-08 21:30:45 +0000196
197</body>
198</html>