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-colon name (NCName) defined in the XML namespace specification.

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

It is a required option if the simpleType element is a child element of the schema element, and it is not allowed otherwise.

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

Instance

Example 1

This example declares that the "age" element is a simple type with constraints. The value of age must not 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>