Stylus Studio XML Editor

Table of contents

Appendices

3.14 Simple Type Definitions

Simple Type Definitions
NOTE: 

This section consists of a combination of non-normative versions of normative material from [ref-xsp2], for local cross-reference purposes, and normative material relating to the interface between schema components defined in this specification and the simple type definition component.

Simple type definitions provide for constraining character information item [children] of element and attribute information items.

NOTE: 
<xs:simpleType name="farenheitWaterTemp">
 <xs:restriction base="xs:number">
  <xs:fractionDigits value="2"/>
  <xs:minExclusive value="0.00"/>
  <xs:maxExclusive value="100.00"/>
 </xs:restriction>
</xs:simpleType>

The XML representation of a simple type definition.

(non-normative) The Simple Type Definition Schema Component[top]

(non-normative) The Simple Type Definition Schema Component

The simple type definition schema component has the following properties:

[Simple Type Definition]

Simple types are identified by their [st-name] and [st-target_namespace]. Except for anonymous simple types (those with no [st-name]), since type definitions (i.e. both simple and complex type definitions taken together) must be uniquely identified within an XML Schema, no simple type definition can have the same name as another simple or complex type definition. Simple type [st-name]s and [ct-target_namespace]s are provided for reference from instances (see [xsi:type]), and for use in the XML representation of schema components (specifically in [element] and [attribute]). See [References to schema components across namespaces] for the use of component identifiers when importing one schema into another.

NOTE: 

The [st-name] of a simple type is not ipso facto the [(local) name] of the element or attribute information items valid by that definition. The connection between a name and a type definition is described in [Element Declarations] and [Attribute Declarations].

A simple type definition with an empty specification for [st-final] can be used as the [st-base_type_definition] for other types derived by either of extension or restriction, or as the [st-item_type_definition] in the definition of a list, or in the [st-member_type_definitions] of a union; the explicit values extension, restriction, list and union prevent further derivations by extension (to yield a complex type) and restriction (to yield a simple type) and use in constructing lists and unions respectively.

[variety] determines whether the simple type corresponds to an atomic, list or union type as defined by [ref-xsp2].

As described in [Type Definition Hierarchy], every simple type definition is a restriction of some other simple type (the [st-base_type_definition]), which is the simple ur-type definition if and only if the type definition in question is one of the built-in primitive datatypes, or a list or union type definition. Each atomic type is ultimately a restriction of exactly one such built-in simple [st-primitive_type_definition].

[facets] for each simple type definition are selected from those defined in [ref-xsp2]. For atomic definitions, these are restricted to those appropriate for the corresponding [st-primitive_type_definition]. Therefore, the value space and lexical space (i.e. what is valid by any atomic simple type) is determined by the pair ([st-primitive_type_definition], [facets]).

As specified in [ref-xsp2], list simple type definitions valid space separated tokens, each of which conforms to a specified simple type definition, the [st-item_type_definition]. The item type specified must not itself be a list type, and must be one of the types identified in [ref-xsp2] as a suitable item type for a list simple type. In this case the [facets] apply to the list itself, and are restricted to those appropriate for lists.

A union simple type definition valid strings which satisfy at least one of its [st-member_type_definitions]. As in the case of list, the [facets] apply to the union itself, and are restricted to those appropriate for unions.

As discussed in [Type Definition Hierarchy], the ur-type definition functions as a simple type when used as the base type definition for the built-in primitive datatypes and for list and union type definitions. It is considered to have an unconstrained lexical space, and a value space consisting of the union of the value spaces of all the built-in primitive datatypes and the set of all lists of all members of the value spaces of all the built-in primitive datatypes.

The simple ur-type definition must not be named as the base type definition of any user-defined simple types: as it has no constraining facets, this would be incoherent.

See [Annotations] for information on the role of the [st-annotation] property.

(non-normative) XML Representation of Simple Type Definition Schema Components[top]

(non-normative) XML Representation of Simple Type Definition Schema Components
NOTE: 

This section reproduces a version of material from [ref-xsp2], for local cross-reference purposes.

[(non-normative) The Simple Type Definition Schema Component]

If the [variety] is atomic, the following additional property mappings also apply:

[(non-normative) The Simple Type Definition Schema Component]

If the [variety] is list, the following additional property mappings also apply:

[(non-normative) The Simple Type Definition Schema Component]

If the [variety] is union, the following additional property mappings also apply:

[(non-normative) The Simple Type Definition Schema Component]

(non-normative) Constraints on XML Representations of Simple Type Definitions[top]

(non-normative) Constraints on XML Representations of Simple Type Definitions Simple Type Definition Representation OK

In addition to the conditions imposed on [simpleType] element information items by the schema for schemas,

  1. The corresponding simple type definition, if any, must satisfy the conditions set out in [Constraints on Simple Type Definition Schema Components].

  2. If the [restriction] alternative is chosen, either it must have a base [attribute] or a [simpleType] among its [children], but not both.

  3. If the [list] alternative is chosen, either it must have an itemType [attribute] or a [simpleType] among its [children], but not both.

  4. Circular union type definition is disallowed. That is, if the [union] alternative is chosen, there must not be any entries in the memberTypes [attribute] at any depth which resolve to the component corresponding to the [simpleType].

Simple Type Restriction (Facets)

For a simple type definition (call it R) to restrict another simple type definition (call it B) with a set of facets (call this S)

  1. The [variety] and [st-primitive_type_definition] of R are the same as those of B.

  2. The [facets] of R are the union of S and the [facets] of B, eliminating duplicates. To eliminate duplicates, when a facet of the same kind occurs in both S and the [facets] of B, the one in the [facets] of B is not included, with the exception of enumeration and pattern facets, for which multiple occurrences with distinct values are allowed.

If [c-fr] above holds, the [facets] of R constitute a restriction of the [facets] of B with respect to S.

Simple Type Definition Validation Rules[top]

Simple Type Definition Validation Rules String Valid

A string is locally valid with respect to a simple type definition if it is schema-valid with respect to that definition as defined by Datatype Valid in [ref-xsp2].

Simple Type Definition Information Set Contributions[top]

Simple Type Definition Information Set Contributions

None as such.

Constraints on Simple Type Definition Schema Components[top]

Constraints on Simple Type Definition Schema Components

All simple type definitions (see [Simple Type Definitions]) must satisfy the following constraints.

Simple Type Definition Properties Correct
  1. The values of the properties of a simple type definition must be as described in the property tableau in [Datatype definition], modulo the impact of [Missing Sub-components].

  2. Circular definitions are disallowed. That is, it must be possible to reach a built-in primitive datatype or the Simple Type Definition of the Ur-Type by repeatedly following the [st-base_type_definition].

  3. The [st-final] of the [st-base_type_definition] must not contain restriction.

  4. If the [st-base_type_definition] is not the Simple Type Definition of the Ur-Type,

    1. The definition must be a valid restriction as defined in [Derivation Valid (Restriction, Simple)].

    2. If [variety] is not atomic, then

      1. ifthe [variety] is list

        thenthe [st-final] of the [st-base_type_definition] must not contain list.

      2. ifthe [variety] is union

        thenthe [st-final] of the [st-base_type_definition] must not contain union.

Derivation Valid (Restriction, Simple)
  1. ifthe [variety] is atomic

    then

    1. The [st-base_type_definition] must be an atomic simple type definition or a built-in primitive datatype.

    2. The [st-final] of the [st-base_type_definition] must not contain restriction.

    3. For each facet in the [facets] there must be a facet of the same kind in the [facets] of the [st-base_type_definition] of whose [value] the facet in question's [value] must be a valid restriction as defined in [ref-xsp2].

  2. ifthe [variety] is list

    then

    1. The [st-item_type_definition] must have a [variety] of atomic or union (in which case all the [st-member_type_definitions] must be atomic).

    2. Only length, minLength, maxLength, pattern and enumeration facet components are allowed among the [facets].

    3. If the [st-base_type_definition] is not the Simple Type Definition of the Ur-Type, then

      1. The [st-base_type_definition] must have a [variety] of list.

      2. The [st-final] of the [st-base_type_definition] must not contain restriction.

      3. for each facet in the [facets] there must be a facet of the same kind in the [facets] of the [st-base_type_definition] of whose [value] the facet in question's [value] must be a valid restriction as defined in [ref-xsp2].

  3. ifthe [variety] is union

    then

    1. The [st-member_type_definitions] must all have [variety] of atomic or list.

    2. Only pattern and enumeration facet components are allowed among the [facets].

    3. If the [st-base_type_definition] is not the Simple Type Definition of the Ur-Type, then

      1. The [st-base_type_definition] must have a [variety] of union.

      2. The [st-final] of the [st-base_type_definition] must not contain restriction.

      3. for each facet in the [facets] there must be a facet of the same kind in the [facets] of the [st-base_type_definition] of whose [value] the facet in question's [value] must be a valid restriction as defined in [ref-xsp2].

If this constraint [Derivation Valid (Restriction, Simple)] holds of a simple type definition, it is a valid restriction of its base type definition.

The following constraint defines relations appealed to elsewhere in this specification.

Type Derivation OK (Simple)

For a simple type definition (call it D, for derived) to be validly derived from a simple type definition (call this B, for base) given a subset of {extension, restriction, list, union} (of which only restriction is actually relevant)

  1. They are the same type definition.

    1. restriction is not in the subset, or in the [st-final] of its own [st-base_type_definition];

      1. D's base type definition is B.

      2. D's base type definition is not the Simple Type Definition of the Ur-Type and is validly derived from B given the subset, as defined by this constraint.

      3. D's [variety] is list or union and B is the Simple Type Definition of the Ur-Type.

      4. B's [variety] is union and D is validly derived from a type definition in B's [st-member_type_definitions] given the subset, as defined by this constraint.

Built-in Simple Type Definition[top]

Built-in Simple Type Definition

There is a simple type definition nearly equivalent to the simple version of the ur-type definition present in every schema by definition. It has the following properties:

Simple Type Definition of the Ur-Type [anySimpleType] [http://www.w3.org/2001/XMLSchema] [st-base_type_definition] [The empty set] [variety]

Simple type definitions for all the built-in primitive datatypes, namely string, boolean, float, double, number, dateTime, duration, time, date, gMonth, gMonthDay, gDay, gYear, gYearMonth, hexBinary, base64Binary, anyURI (see the Primitive Datatypes section of [ref-xsp2]), as well as for the simple and complex ur-type definition (as previously described), are present by definition in every schema. All are in the XML Schema [st-target_namespace] (namespace name http://www.w3.org/2001/XMLSchema), have an atomic [variety] with an empty [facets] and the simple ur-type definition as their base type definition and themselves as [st-primitive_type_definition].

Similarly, simple type definitions for all the built-in derived datatypes (see the Derived Datatypes section of [ref-xsp2]) are present by definition in every schema, with properties as specified in [ref-xsp2] and as represented in XML in [Schema for Schemas (normative)].