Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - XML Schemas

simpleType

Defines a simple type, which determines the constraints on and information about the values of attributes or elements with text-only content.

<simpleType
  final = (#all | (list | union | restriction)) 
  id = ID 
  name = NCName 
  {any attributes with non-schema Namespace}…>
Content: (annotation?, (restriction | list | union))
</simpleType>

Attributes

final
The type of derivation. The final attribute prevents the specified type of derivation of this simpleType element. This value can contain #all or a list that is a subset of list, union, or restriction.

list Prevents derivation by list.
union Prevents derivation by union.
restriction Prevents derivation by restriction.
#all Prevents all derivation (list, union, restriction).

Optional.

id
The ID of this element. The id value must be of type ID and be unique within the document containing this element.

Optional.

name
The name of the type. The name must be a no-colon-name (NCName) as defined in the XML Namespaces specification.

If specified, the name must be unique among all simpleType and complexType elements.

Required if the simpleType element is a child of the schema element, and not allowed at other times.

Element Information

Number of occurrences Unlimited
Parent elements attribute, element, list, restriction (simpleType), schema, union
Contents annotation, list, restriction (simpleType), union

Remarks

Simple types are defined by deriving them from existing simple types (built-in data types and derived simple types). A simple type cannot contain elements and cannot have attributes.

Simple types can be defined in one of the following ways.

restriction Restricts the range of values for the simple type to a subset of those for inherited simple type.
list Defines a simple type that contains a white space-separated list of values of an inherited simple type.
union Defines a simple type that contains a union of the values of two or more inherited simple types.

A simpleType declaration contained within a complexType or attribute element defines that simple type within the scope of the complexType or attribute that contains it. If a simpleType declaration has the schema element as its parent, it has global scope within that schema.

After a simple type is defined, it can be used in an attribute or element declaration or complexType (which, in turn, can be used in an element declaration) definition.

Examples

The following examples show simple type definitions using restriction, list, and union elements.

Restriction

<xs:simpleType name="freezeboilrangeInteger">
  <xs:restriction base="xs:integer">
    <xs:minInclusive value="0"/>
    <xs:maxInclusive value="100"/>
  </xs:restriction>
</xs:simpleType>

List

<xs:simpleType name="listOfDates">
  <xs:list itemType="xs:date">
</xs:simpleType>

Union

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:attribute name="allframesize">
  <xs:simpleType>
    <xs:union>
      <xs:simpleType>
        <xs:restriction base="roadbikesize"/>
      </xs:simpleType>
      <xs:simpleType>
        <xs:restriction base="mountainbikesize"/>
      </xs:simpleType>
    </xs:union>
  </xs:simpleType>
</xs:attribute>

<xs:simpleType name="roadbikesize">
  <xs:restriction base="xs:positiveInteger">
    <xs:enumeration value="46"/>
    <xs:enumeration value="52"/>
    <xs:enumeration value="55"/>
  </xs:restriction>
</xs:simpleType>

<xs:simpleType name="mountainbikesize">
  <xs:restriction base="xs:string">
    <xs:enumeration value="small"/>
    <xs:enumeration value="medium"/>
    <xs:enumeration value="large"/>
  </xs:restriction>
</xs:simpleType>
</xs:schema>

See Also

XML Schema Reference (XSD) | XML Schema Elements

For more information, see the W3C XML Schema Part 1: Structures Recommendation at http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-simpleType.

Other Resources Other Resources

W3C Namespaces in XML Recommendation