XML Schema simpleType element

Definition and usage

The simpleType element defines a simple type, specifying information and constraints related to the values of elements or attributes with pure text content.

Element information

Occurrence Unrestricted
Parent element attribute, element, list, restriction (simpleType), schema, union
Content annotation, list, restriction (simpleType), union

Syntax

<simpleType
id=ID
name=NCName
any attributes
>
(annotation?,(restriction|list|union))
</simpleType>

(The symbol declaration element can appear zero or once in the simpleType element.)

Attributes Description
id Optional. Specifies a unique ID for the element.
name

Type name. The name must be a non-colonized name (NCName) defined in the XML namespace specification.

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

If the simpleType element is a child element of the schema element, it is required, otherwise it is not allowed.

any attributes Optional. Specifies any other attributes with non-schema namespaces.

Instance

Example 1

In this example, the "age" element is declared as a simple type with constraints. The value of age cannot be less than 0 or greater than 100:

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