Easy Tutorial
❮ El Any El Field ❯

XML Schema restriction Element



Definition and Usage

The restriction element defines constraints on a simpleType, simpleContent, or complexContent definition.

Element Information

Syntax

(? symbol indicates that the element can appear zero or one time within the restriction element.)

Attribute Description
id Optional. Specifies a unique ID for the element.
base Required. Specifies the name of a built-in data type, simpleType, or complexType element defined in this schema (or another schema indicated by the specified namespace).
any attributes Optional. Specifies any other attributes with non-schema namespaces.

Example 1

The following example defines an element named "age" with constraints. The value of age cannot be less than 0 or greater than 100:

Example 2

This example defines an element named "initials". The "initials" element is a simple type with constraints. The acceptable values are three uppercase or lowercase letters from a to z:

Example 3

This example defines an element named "password". The "password" element is a simple type with constraints. The value must be between 5 and 8 characters long:

Example 4

This example shows a complex type definition using constraints. The complex type "Chinese_customer" is derived from a regular customer complex type, with the fixed value of the country element being "China":


❮ El Any El Field ❯