# Adding a simple type

In the XML schema editor, you can add a simple type to an XML schema. 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 simple types.

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:

1. Open your XML schema in the XML schema editor.
2. In the Outline view, select your schema. The entire schema and its contents should be displayed in the Graph view.
3. In the Graph view, right click in the Types section and click Add Simple Type.
4. In the Properties view, click the General tab, and type a new name for the simple type in the Name field.
5. You can select the following options from the Variety drop down 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
6. If you selected atomic from the Variety drop down list, click the More button next to the Base type field to specify a base type for the simple type. You can select either a Built-in simple type, or User-defined simple type to be the base type.
7. If you selected list from the Variety drop down list, click the More button next to the Item type field to specify a item type for the simple type. You can select either a Built-in simple type, or User-defined simple type to be the item type.
8. If you selected union from the Variety drop down list, click the More button next to the Member types field to specify the member types for the simple type. You can select both Built-in simple type, or User-defined simple type to add to the member types list.
9. Click the Enumerations tab. Enumerations help you to define a set of valid values for simple types. Enumerations 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:
   1. To add one enumeration at a time, click the Add button and specify a value for the enumeration.
   2. To add several enumerations at one time, follow these steps:
      1. Click the Add... button.
      2. 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".
      3. 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.
      4. Click OK. Your enumerations will be created and appear in the Properties view.
10. 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.
11. 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.
12. 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.
    1. 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
    2. 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.
13. If applicable to the type, a Pattern page will be available. Click the Pattern 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.

(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.