Using XML Schema Built-in Datatypes

This section describes what is a built-in datatype and how to use a built-in datatype.

XML Schema 1.0 specification provides about 46 built-in datatypes. Here are some examples of built-in datatypes:

Rule 1. All built-in datatypes are simple datatypes, which do not allow any attributes or sub (child) elements if it is used in an element declaration component.

Rule 2. Build-in datatype names have the namespace name of "".

Here is a sample schema, holiday.xsd, that uses the built-in datatype "date":

<?xml version="1.0"?>
<xs:schema xmlns:xs="">
<!-- holidat.xsd
 - Copyright (c) 2013,, All Rights Reserved.

 <!-- Using XML Schema built-in datatype "date" -->
 <xs:element name="holiday" type="xs:date"/>


The following XML document, holiday.xml, conforms to holiday.xsd:

<?xml version="1.0"?>

The following XML document, holiday_error.xml, does not conform to holiday.xsd, because the content of "holiday" element is not a "date" value:

<?xml version="1.0"?>
<holiday>New Year Day</holiday>

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

 Schema and Schema XML Representation

 Checking Schema Documents -

 Creating Schema Documents - "schema" Element

 Declaring Root Elements - "element" Element

 Specifying Element Datatype - "type" Attribute

Using XML Schema Built-in Datatypes

 Using XML Schema Built-in Datatypes Incorrectly

 Validating XML Documents against Schema Documents

 Deriving New Simple Datatypes - "simpleType" Element

 Defining Complex Datatypes - "complexType" Element

 Validation Error Examples on Complex Datatypes

 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

 "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



 PDF Printing Version