XML Schema Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 4.00

List of Built-in Datatypes

This section lists all built-in datatypes supported in XML Schema.

XML Schema built-in (pre-defined) datatypes are divided into 7 groups:

  • Numeric datatypes
  • Date and time datatypes
  • String datatypes
  • Binary datatypes
  • Boolean datatype

Numeric datatypes: All commonly used integer and real number datatypes:

  • float
  • double
  • decimal
  • integer
  • nonPositiveInteger
  • nonNegativeInteger
  • negativeInteger
  • positiveinteger
  • long
  • int
  • short
  • byte
  • unsignedLong
  • unsignedInt
  • unsignedShort
  • unsignedByte

Date and time datatypes: Date and time related data types. Constants of date and time types are written in the format defined by ISO 8601. For example: "2002-12-23T14:19:00.000-05:00" represents an instance of time at 14:19:00.000 on December 23, 2003, with 5:00 time zone adjustment.

  • dateTime - Date and time, like "2002-12-23T14:19:00.000-05:00".
  • date - Date only, like "2002-12-23".
  • time - Time only, like "14:19:00.000-05:00".
  • gDay - Day only, like "--23" (the 23rd day of any month of any year).
  • gMonth - Month only, like "-12" (December of any year).
  • gYear - Year only, like "2002".
  • gYearMonth - Year and month only, like "2002-12".
  • gMonthDay - Month and day only, like "-12-23".
  • duration - Period of time, like "P0001Y02M03DT04H05M06.000S".

String datatypes: String related data types.

  • string - A sequence of any Unicode characters
  • normalizedString - A string with no tabs, carriage returns, or line feeds
  • token - A normalized string with no any leading and trailing spaces, and no multiple consecutive spaces.
  • language - A string that matches this pattern "[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*". Obviously, "language" datatype is designed to define variables used in many programming languages.
  • NMTOKEN - A string that matches the NMTOKEN attribute type from XML 1.0.
  • NMTOKENS - A list of NMTOKEN.
  • Name - A string that matches the Name production of XML 1.0.
  • NCName - A string that matches the "non-colonized" Name production of XML 1.0.
  • ID - A string that matches the ID attribute type from XML 1.0.
  • IDREF - A string that matches the IDREF attribute type from XML 1.0.
  • IDREFS - A list of IDREF.
  • ENTITY - A string that matches the ENTITY attribute type from XML 1.0.
  • ENTITIES - A list of ENTITY.
  • anyURI - A string represents a Uniform Resource Identifier Reference (URI).
  • QName - A string represents XML qualified names, an optional namespace name and a local name.
  • NOTATION - A string that matches the NOTATION attribute type from XML 1.0.

Binary datatypes:

  • hexBinary - A sequence of hex digits to represent any binary data.
  • base64Binary - Binary data written in Base64 encoding

Boolean data type:

  • boolean - With 4 possible values: 0, 1, true, false.

Sections in This Chapter

Overview of XML Schema Built-in Datatypes

List of Built-in Datatypes

Deriving from Built-in Datatypes - simpleType

Built-in Datatype - "string"

Built-in Datatype - "string" Errors

Built-in Datatype - "dateTime"

Built-in Datatype - "dateTime" Errors

Built-in Datatype - "decimal"

Built-in Datatype - "decimal" Errors

Dr. Herong Yang, updated in 2007
List of Built-in Datatypes