XML Schema simpleTypeElement


XML Schema 参考手册Complete XML Schema Reference Manual

Definition and Usage

The simpleType element defines a simple type, specifying information about and constraints on the values of elements or attributes with plain text content.

Element Information

  • Parent elements: attribute, element, list, restriction, schema, union

Syntax

<simpleType
id=ID
name=NCName
any attributes
>

(annotation?,(restriction|list|union))

</simpleType>

(The ? symbol declares that the element can appear zero or one time within the simpleType element.)

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

The name of the type. This name must be a colon-free name (NCName) as defined in the XML Namespace specification.

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

Required if the simpleType element is a child of the schema element; otherwise it is not allowed.

any attributes Optional. Specifies any other attributes with a non-schema namespace.

Example 1

This example declares the "age" element 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>


XML Schema 参考手册Complete XML Schema Reference Manual Other Extensions