|
Home > Online Product Documentation > Table of Contents > Defining simpleTypes in XML Schemas Defining simpleTypes in XML Schemas
Many simpleTypes, such as
This section covers the following topics: About simpleTypes in XML SchemasXML Schema defines several kinds of simpleTypes:
Descriptions of the XML Schema built-in types are in the W3C XML Schema Part 2: Datatypes. Anonymous simpleTypes are useful when you want to define a type that is used in only one element or attribute. By specifying an anonymous simpleType, you save the overhead of explicitly defining the type and specifying a reference to it. Examples of simpleTypes in an XML SchemaThe W3C XML Schema Part 0: Primer specifies the following simpleType in its sample purchase order schema:
This specifies that
The
Elsewhere in the purchase order schema, an attribute definition specifies that SKU is the type of its value:
An XML document that uses a schema that contains this simpleType definition can specify the
Following is another example of a simpleType definition from the W3C XML Schema Part 0: Primer. This simpleType,
Defining a simpleType in the Diagram ViewThis section describes the procedures for defining simpleTypes in the Diagram view. It covers the following topics: Before You BeginMany of the editing features used in this section are described in Defining an XML Schema Using the Diagram Tab - Getting Started. You should familiarize yourself with that material if you have not done so already. Defining an Atomic simpleTypeThis topic provides the steps for defining an atomic simpleType in the Diagram view. In the Diagram view, to define an atomic simple type:
1. Right-click the
schema node
2. Select
Add >
simpleType.
The new simpleType appears in the diagram; its properties are displayed in the Properties window.
3. Change the default name to the name of the new simpleType and press Enter.
Specifying a Restriction for a simpleType - QuickEditQuickEdit is a feature that combines commonly-performed editing operations, such as specifying a restriction for a simpleType. You can also perform this operation in a different way. See Specifying a Restriction for a simpleType - Manually. To specify a restriction for a simple type using QuickEdit:
1. Right-click the
simpleType node
2. Select
QuickEdit > Derive by restriction from the shortcut menu.
The Type Derivation dialog box appears.
The Type Derivation dialog box displays the W3C XML Schema, as well as any referenced XML Schemas.
3. Expand the schema (click the plus sign) to display the base types associated with that XML Schema.
4. Select the type on which you wish to base the simpleType you are defining and click OK.
The simpleType is updated with an element that identifies the restricted type:
In the lower half of the Properties window, Stylus Studio displays a section that allows you to specify facets - values that define the constraint on the range of values allowed by the base type.
5. Click the
Name field and select a facet type.
Stylus Studio displays only those facets that are allowed for the base type you selected. For a description of each facet, see About Facet Types for simpleTypes.
6. Click the
Value field for a facet you want to specify.
7. Enter a value for the new facet.
Specifying a Restriction for a simpleType - ManuallyThis procedure describes how to specify a restriction for a simpleType manually. It is an alternative to the procedure described in Specifying a Restriction for a simpleType - QuickEdit. To specify a restriction for a simple type manually:
1. Right-click the
simpleType node to display the shortcut menu.
2. Select
Add > Restriction from the shortcut menu.
The simpleType is updated with a restriction icon:
3. Select the restriction icon if it is not already selected.
4. In the
Properties window, select the type on which you want to base the simpleType you are defining from the
Base Type field.
At the bottom of the Properties window, Stylus Studio displays a section that allows you to specify facets - values that define the constraint on the range of values provided by the base type.
5. Click the
Name field and select a facet type.
Stylus Studio displays only those facets that are allowed for the base type you selected. For a description of each facet, see About Facet Types for simpleTypes.
6. Click the
Value field for a facet you want to specify.
7. Enter a value for the new facet.
Defining List and Union simpleTypes
The procedure for defining
1. Create the
simpleType as described in
Defining a simpleType in the Diagram View.
2. Select the type (list or union) from the shortcut menu (right-click the new
simpleType and select
Add > List or
Add > Union).
3. Specify the nodes that comprise the
simpleType's
list or
union. These types are restricted to
annotations and other
simpleTypes.
How you perform this last step depends on whether you are adding new or existing
Notice that the pointer changes shape when you place it over an appropriate target node. Defining a simpleType in the Tree ViewThis topic provides the steps for defining an atomic simpleType in the Tree view. When you are familiar with this procedure, you can adapt it to define list, union, and anonymous simpleTypes. In the Tree view, to define an atomic simple type:
1. Click the node you want to define a simpleType for. This can be one of the following types of nodes:
To define a simpleType as the sibling of another node, click the node and hold down the Shift key when you click the button in step 2. You cannot, of course, define a simpleType as a sibling of the Schema node.
2. In the left tool bar, click
New simpleType
3. Type a name for the new simpleType and press Enter.
4. In the left tool bar, click
New Restriction
Stylus Studio displays a scrollable list of XML Schema built-in types, and any simpleTypes you already defined in this schema. Descriptions of the XML Schema built-in types are in the W3C XML Schema Part 0: Primer.
5. Double-click the simpleType that you want to base your new simpleType on.
6. In the left tool bar, click
New Facet
You must ensure that you specify a facet that is valid for the specified base type. Stylus Studio does not prevent you from specifying an invalid facet. The W3C XML Schema Part: 0 Primer includes a table that provides this information.
7. Double-click the type of facet you want to specify.
8. In the
Properties window, double-click the
Value field.
9. Enter a value for the new facet.
10. To add another facet, click the
restriction node for your simpleType, and repeat
step 6 through
step 9.
About Facet Types for simpleTypesTable 36 provides a brief description of what you should specify as the value of a facet for a new simpleType. You should consult the XML Schema Recommendation for a complete definition of each facet and its allowable values.
Defining List and Union simpleTypes in the Tree View
Sometimes you need to define a simpleType for a sequence of atomic types. In a
In the Tree view, to define a list or union simple type:
1. Click the node you want to define the
list or
union type for.
2. In the left tool bar, click
New simpleType
3. Type a name for the new simpleType and press Enter.
4. In the left tool bar, click
New Aggregator
5. Double-click
list or
union.
6. Define the atomic simpleType of the elements or attributes that are instances of the
list or
union type. See
Defining simpleTypes in XML Schemas.
7. If you are defining a
list type you are done. If you are defining a
union type, click the
union node and define another atomic simpleType that can be in the union. Perform this step for each type in the union.
|

Cart


