XSD Tutorials - Herong's Tutorial Examples - Version 5.11, by Dr. Herong Yang
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
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
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
►Constructing New Datatypes with Restriction Facets
Facets Supported in "dateTime"
"simpleType" - Defining Your Own Simple Datatypes
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