Tutorials References Exercises Bootcamps Videos Menu
Sign Up Create Website Get Certified Upgrade

XML Tutorial

XML HOME XML Introduction XML How to use XML Tree XML Syntax XML Elements XML Attributes XML Namespaces XML Display XML HttpRequest XML Parser XML DOM XML XPath XML XSLT XML XQuery XML XLink XML Validator XML DTD XML Schema XML Server XML Examples XML Quiz XML Certificate


AJAX Introduction AJAX XMLHttp AJAX Request AJAX Response AJAX XML File AJAX PHP AJAX ASP AJAX Database AJAX Applications AJAX Examples


DOM Introduction DOM Nodes DOM Accessing DOM Node Info DOM Node List DOM Traversing DOM Navigating DOM Get Values DOM Change Nodes DOM Remove Nodes DOM Replace Nodes DOM Create Nodes DOM Add Nodes DOM Clone Nodes DOM Examples

XPath Tutorial

XPath Introduction XPath Nodes XPath Syntax XPath Axes XPath Operators XPath Examples

XSLT Tutorial

XSLT Introduction XSL Languages XSLT Transform XSLT <template> XSLT <value-of> XSLT <for-each> XSLT <sort> XSLT <if> XSLT <choose> XSLT Apply XSLT on the Client XSLT on the Server XSLT Edit XML XSLT Examples

XQuery Tutorial

XQuery Introduction XQuery Example XQuery FLWOR XQuery HTML XQuery Terms XQuery Syntax XQuery Add XQuery Select XQuery Functions


DTD Introduction DTD Building Blocks DTD Elements DTD Attributes DTD Elements vs Attr DTD Entities DTD Examples

XSD Schema

XSD Introduction XSD How To XSD <schema> XSD Elements XSD Attributes XSD Restrictions XSD Complex Elements XSD Empty XSD Elements-only XSD Text-only XSD Mixed XSD Indicators XSD <any> XSD <anyAttribute> XSD Substitution XSD Example

XSD Data Types

XSD String XSD Date/Time XSD Numeric XSD Misc XSD Reference

Web Services



DOM Node Types DOM Node DOM NodeList DOM NamedNodeMap DOM Document DOM Element DOM Attribute DOM Text DOM CDATA DOM Comment DOM XMLHttpRequest DOM Parser XSLT Elements XSLT/XPath Functions

XML Schema restriction Element

❮ Complete XML Schema Reference

Definition and Usage

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

Element Information

  • Parent elements: simpleType, simpleContent, complexContent


any attributes

Content for simpleType:

Content for simpleContent:
(annotation?,(simpleType?,(minExclusive |minInclusive|

Content for complexContent:


(The ? sign declares that the element can occur zero or one time inside the restriction element)

Attribute Description
id Optional. Specifies a unique ID for the element

Required. Specifies the name of a built-in data type, simpleType element, or complexType element defined in this schema or another schema

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

Example 1

This example defines an element called "age" with a restriction. The value of age can NOT be lower than 0 or greater than 100:

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

Example 2

This example also defines an element called "initials". The "initials" element is a simple type with a restriction. The only acceptable value is THREE of the LOWERCASE OR UPPERCASE letters from a to z:

<xs:element name="initials">
    <xs:restriction base="xs:string">
      <xs:pattern value="[a-zA-Z][a-zA-Z][a-zA-Z]"/>

Example 3

This example defines an element called "password". The "password" element is a simple type with a restriction. The value must be minimum five characters and maximum eight characters:

<xs:element name="password">
    <xs:restriction base="xs:string">
      <xs:minLength value="5"/>
      <xs:maxLength value="8"/>

Example 4

This example shows a complex type definition using restriction. The complex type "Norwegian_customer" is derived from a general customer complex type and its country element is fixed to "Norway":

<xs:complexType name="customer">
    <xs:element name="firstname" type="xs:string"/>
    <xs:element name="lastname" type="xs:string"/>
    <xs:element name="country" type="xs:string"/>

<xs:complexType name="Norwegian_customer">
    <xs:restriction base="customer">
        <xs:element name="firstname" type="xs:string"/>
        <xs:element name="lastname" type="xs:string"/>
        <xs:element name="country" type="xs:string" fixed="Norway"/>

❮ Complete XML Schema Reference