Constructing New Datatypes with Restriction Facets

This section describes how 'restriction' components with facets can be used to construct new user-defined datatypes by applying restrictions on a single base datatype. The resulting datatype's value space is a subset of the base datatype's value space.

From the previous tutorial we learned what facets are supported in simple built-in datatypes, now let's see how we use them to contruct new user-defined simple datatypes.

Here some general rules on constructing a new user-defined simple datatype with restriction facets:

Here is a schema template that constructs a user-defined datatype from a base datatype:

<simpleType name="my_type_name">
 <restriction base="base_type_name">
  <facet_name value="facet_value">
  <facet_name value="facet_value">
  ...
 </restriction>
</simpleType>
...
<element name="element_name" type="my_type_name"/>
...
<attribute name="attribute_name" type="my_type_name"/>
...

In the template, "base_type_name" should be any simple datatype that supports restriction facets (constraining facets). "my_type_name" is the new user-defined datatype to be constructed.

Last update: 2013.

Table of Contents

 About This Book

 Introduction to XML Schema

 XML Editor and Schema Processor - XMLPad

 Java API for XML Processing - JAXP

 JAXP - XML Schema (XSD) Validation

 Xerces2 Java Parser - Java API of XML Parsers

 Using Xerces2 Java API

 XML Schema Language - Basics

 Introduction of XSD Built-in Datatypes

 "string" and Its Derived Datatypes

 "decimal" and Its Derived Datatypes

 "dateTime" and Its Related Datatypes

 Miscellaneous Built-in Datatypes

Facets, Constraining Facets and Restriction Datatypes

 What Is Facet?

 List of Facets

Constructing New Datatypes with Restriction Facets

 Facets Supported in "string"

 Facets Supported in "dateTime"

 Facets Supported in "decimal"

 "simpleType" - Defining Your Own Simple Datatypes

 Complex Element Declaration

 Identity-Constraints: unique, key and keyref

 Assertion as Custom Validation Rules

 XML Schema Location and Namespace in XML Documents

 Overriding Element Types in XML Documents

 Linking Multiple Schema Documents Together

 Glossary

 References

 PDF Printing Version