Stylus Studio XML Editor

Table of contents

Appendices

4.1 Simple Type Definition

Simple Type Definition

Simple Type definitions provide for:

The Simple Type Definition Schema Component[top]

The Simple Type Definition Schema Component

The Simple Type Definition schema component has the following properties:

[Datatype]

Datatypes are identified by their [defn-name] and [defn-target-namespace]. Except for anonymous datatypes (those with no [defn-name]), datatype definitions must be uniquely identified within a schema.

If [defn-variety] is atomic then the value space of the datatype defined will be a subset of the value space of [defn-basetype] (which is a subset of the value space of [defn-primitive]). If [defn-variety] is list then the value space of the datatype defined will be the set of finite-length sequence of values from the value space of [defn-itemType]. If [defn-variety] is union then the value space of the datatype defined will be the union of the value spaces of each datatype in [defn-memberTypes].

If [defn-variety] is atomic then the [defn-variety] of [defn-basetype] must be atomic. If [defn-variety] is list then the [defn-variety] of [defn-itemType] must be either atomic or union. If [defn-variety] is union then [defn-memberTypes] must be a list of datatype definitions.

The value of [defn-facets] consists of the set of facets specified directly in the datatype definition unioned with the possibly empty set of [defn-facets] of [defn-basetype].

The value of [defn-fund-facets] consists of the set of fundamental facets and their values.

If [defn-final] is the empty set then the type can be used in deriving other types; the explicit values restriction, list and union prevent further derivations by restriction, list and union respectively.

XML Representation of Simple Type Definition Schema Components[top]

XML Representation of Simple Type Definition Schema Components

The XML representation for a [The Simple Type Definition Schema Component] schema component is a [simpleType] element information item. The correspondences between the properties of the information item and properties of the component are as follows:

[The Simple Type Definition Schema Component]

A derived datatype can be derived from a primitive datatype or another derived datatype by one of three means: by restriction, by list or by union.

Derivation by restriction[top]

Derivation by restriction [The Simple Type Definition Schema Component]
NOTE: 

An electronic commerce schema might define a datatype called Sku (the barcode number that appears on products) from the built-in datatype [string] by supplying a value for the pattern facet.

<simpleType name='Sku'>
    <restriction base='string'>
      <pattern value='\d{3}-[A-Z]{2}'/>
    </restriction>
</simpleType>

In this case, Sku is the name of the new user-derived datatype, [string] is its base type and pattern is the facet.

Derivation by list[top]

Derivation by list [The Simple Type Definition Schema Component]

A list datatype must be derived from an atomic or a union datatype, known as the itemType of the list datatype. This yields a datatype whose value space is composed of finite-length sequences of values from the value space of the itemType and whose lexical space is composed of white space separated lists of literals of the itemType.

NOTE: 

A system might want to store lists of floating point values.

<simpleType name='listOfFloat'>
  <list itemType='float'/>
</simpleType>

In this case, listOfFloat is the name of the new user-derived datatype, [float] is its itemType and list is the derivation method.

As mentioned in [List datatypes], when a datatype is derived from a list datatype, the following constraining facets can be used:

regardless of the constraining facets that are applicable to the atomic datatype that serves as the itemType of the list.

For each of length, maxLength and minLength, the unit of length is measured in number of list items. The value of whiteSpace is fixed to the value collapse.

Derivation by union[top]

Derivation by union [The Simple Type Definition Schema Component]

A union datatype can be derived from one or more atomic, list or other union datatypes, known as the memberTypes of that union datatype.

NOTE: 

As an example, taken from a typical display oriented text markup language, one might want to express font sizes as an integer between 8 and 72, or with one of the tokens "small", "medium" or "large". The union type definition below would accomplish that.

<xsd:attribute name="size">
  <xsd:simpleType>
    <xsd:union>
      <xsd:simpleType>
        <xsd:restriction base="xsd:positiveInteger">
          <xsd:minInclusive value="8"/>
          <xsd:maxInclusive value="72"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType>
        <xsd:restriction base="xsd:NMTOKEN">
          <xsd:enumeration value="small"/>
          <xsd:enumeration value="medium"/>
          <xsd:enumeration value="large"/>
        </xsd:restriction>
      </xsd:simpleType>
    </xsd:union>
  </xsd:simpleType>
</xsd:attribute>
<p>
<font size='large'>A header</font>
</p>
<p>
<font size='12'>this is a test</font>
</p>

As mentioned in [Union datatypes], when a datatype is derived from a union datatype, the only following constraining facets can be used:

regardless of the constraining facets that are applicable to the datatypes that participate in the union

Constraints on XML Representation of Simple Type Definition[top]

Constraints on XML Representation of Simple Type Definition Single Facet Value

Unless otherwise specifically allowed by this specification ([Multiple patterns] and [Multiple enumerations]) any given constraining facet can only be specifed once within a single derivation step.

itemType attribute or simpleType child

Either the itemType   [attribute] or the [simpleType]  [child] of the [Derived by list] element must be present, but not both.

base attribute or simpleType child

Either the base   [attribute] or the simpleType  [child] of the [Derived by restriction] element must be present, but not both.

memberTypes attribute or simpleType children

Either the memberTypes   [attribute] of the [Derived by union] element must be non-empty or there must be at least one simpleType  [child].

Simple Type Definition Validation Rules[top]

Simple Type Definition Validation Rules Facet Valid

A value in a value space is facet-valid with respect to a constraining facet component if:

  1. the value is facet-valid with respect to the particular constraining facet as specified below.

Datatype Valid

A string is datatype-valid with respect to a datatype definition if:

  1. it matches a literal in the lexical space of the datatype, determined as follows:

    1. if pattern is a member of [defn-facets], then the string must be [pattern valid];

    2. if pattern is not a member of [defn-facets], then

      1. if [defn-variety] is atomic then the string must match a literal in the lexical space of [defn-basetype]

      2. if [defn-variety] is list then the string must be a sequence of white space separated tokens, each of which matches a literal in the lexical space of [defn-itemType]

      3. if [defn-variety] is union then the string must match a literal in the lexical space of at least one member of [defn-memberTypes]

  2. the value denoted by the literal matched in the previous step is a member of the value space of the datatype, as determined by it being [Facet Valid] with respect to each member of [defn-facets] (except for pattern).

Constraints on Simple Type Definition Schema Components[top]

Constraints on Simple Type Definition Schema Components applicable facets

The constraining facets which are allowed to be members of [defn-facets] are dependent on [defn-basetype] as specified in the following table:

list of atomic

If [defn-variety] is list, then the [defn-variety] of [defn-itemType]  must be atomic or union.

no circular unions

If [defn-variety] is union, then it is an error if [defn-name] and [defn-target-namespace]  match [defn-name] and [defn-target-namespace] of any member of [defn-memberTypes].

Simple Type Definition for anySimpleType[top]

Simple Type Definition for anySimpleType

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:

[ ]