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.
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.
The
following instructions were written for the Resource perspective, but they
will also work in many other perspectives.
To add a simple type, follow
these steps:
- Open your XML schema in the XML schema editor.
- In the Outline view, select your schema. The
entire schema and its contents should be displayed in the Graph view.
- In the Graph view, right-click in the Types section
and click Add Simple Type.
- In the Properties view, click the General tab,
and type a new name for the simple type in the Name field.
- You can select the following options from the Variety list:
- atomic. Atomic types are all the
simple types built into the XML schema language.
- list. List types are comprised of
sequences of atomic types. They have values that are comprised of finite-length
sequences of atomic values.
- union. 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.
- If you selected atomic from
the Variety drop down list, click
the Browse
button next to the Base
type field to specify a base type for the simple type. The
Set Type dialog lists all built-in and user-defined types currently available.
You can change the Scope of the list
by selecting one of the following options:
- Workspace. Lists all of the types
available in your workspace.
- Enclosing Project. Lists all of
the types available in the project that contains your file.
- (Default) Current Resource. List
all of the types available in your current file.
- If you selected list from
the Variety drop down list, click
the Browse
button next to the Item
type field to specify a item type for the simple type. The
Set Type dialog lists all built-in and user-defined types currently available.
You can change the Scope of the list
by selecting one of the following options:
- Workspace. Lists all of the types
available in your workspace.
- Enclosing Project. Lists all of
the types available in the project that contains your file.
- (Default) Current Resource. List
all of the types available in your current file.
- If you selected union from
the Variety drop down list, click
the Browse
button next to the Member
types field to specify the member types for the simple type. You
can select to add both Built-in simple types and User-defined simple types to the member types
value list.
- Click the Enumerations tab. 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:
- To add one enumeration at a time, click the
Add button and specify a value for
the enumeration.
- To add several enumerations at one time, follow
these steps:
- Click the Add... button.
- Enter the value of each enumeration. Each value must be separated by the Delimiter character. For example: First,
Second will create two enumerations, one with the value "First" and
one with the value "Second".
- Select the Preserve leading and trailing whitespace 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 First,
Second will show up as "First" and " Second" (there is a space before
Second) because you put a space before "Second" when entered the value.
- Click OK. Your enumerations will
be created and appear in the Properties view.
- Click the Documentation tab
if you want to provide any information about this simple type. The Documentation page is used for human readable material,
such as a description, and the App Info page
can be used to provide information for applications.
- Click the Advanced tab. The
options available from this page will vary depending on what option you selected
in the Variety field, and the Base type, Item type, or Member types field on the General page.
- If applicable to the type, the Facets 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.
- To change a facet's value, click its name in the Name column,
then click its value (or the empty cell that will contain its value) in the Value column and type or select a new value.
- 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.
- If applicable to the type, a Pattern page will
be available. Click the Patterns tab
to switch to it. 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.
Related tasks
Adding
pattern facets to simple types