|
|
|
|
Adding simple types
Simple types are used to create derived data types. 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.
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.
The
following instructions were written for the Resource perspective,
but they will also work in many other perspectives.
To add a
simple type, complete the following steps:
-
Open your XML schema in the XML schema editor.
-
In the Outline view, right-click Types, and click Add
Simple Type.
-
In the Outline view, select the new simple type.
-
In the Properties view, click the General tab.
-
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: union types enable 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 or list from
the Variety list, click Browse next to the Base type or Item
type field to specify a base type for the simple type.
The Set Type dialog box 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: lists all of
the types available in your current file.
-
Working Sets: lists all the types available
within the selected working set.
-
If you selected union from the Variety list,
click Browse 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.
-
To set specific constraint values on your simple type,
such as length constraints, enumerations, and patterns, click the Constraints tab.
-
You can use enumerations 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 add one
enumeration or several enumerations at a time:
- To add one enumeration at a time, under Specific constraint
values, select Enumerations and
click Add and specify a value for the enumeration.
- To add several enumerations at one time:
- Select Enumerations and click Add.
- 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 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
entering the value.
- Click OK. Your enumerations will be created
and appear in the Properties view.
-
You can use patterns to place certain constraints
regarding allowable values. 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:
- Select Patterns and click Add.
- Create the regular expression pattern you wish to use as your
constraint using the Regular Expression wizard.
- Click Finish.
-
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.
-
Click the Extensions tab if you
want to add application information elements to your annotations of
schema components. The Extensions page
allows you to specify the schema and add XML content to your annotations.
-
If you do not want the simple type to be used to derive
other types, click the Advanced tab and, in
the Final list, select if derivations should
be prevented by list, restriction, union or #all.
|
|
|