W3C

W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes

W3C Working Draft 30 January 2009

This version:
http://www.w3.org/TR/2009/WD-xmlschema11-2-20090130/
Latest version:
http://www.w3.org/TR/xmlschema11-2/
Previous versions:
http://www.w3.org/TR/2008/WD-xmlschema11-2-20080620/ http://www.w3.org/TR/2006/WD-xmlschema11-2-20060217/ http://www.w3.org/TR/2006/WD-xmlschema11-2-20060116/ http://www.w3.org/TR/2005/WD-xmlschema11-2-20050224/ http://www.w3.org/TR/2004/WD-xmlschema11-2-20040716/
Editors:
Version 1.1:
David Peterson, invited expert (SGMLWorks!) <davep@iit.edu>
Shudi (Sandy) Gao 高殊镝, IBM <sandygao@ca.ibm.com>
Ashok Malhotra, Oracle Corporation <ashokmalhotra@alum.mit.edu>
C. M. Sperberg-McQueen, World Wide Web Consortium <cmsmcq@w3.org>
Henry S. Thompson, University of Edinburgh <ht@inf.ed.ac.uk>
Version 1.0:
Paul V. Biron, Kaiser Permanente, for Health Level Seven <Paul.V.Biron@kp.org>
Ashok Malhotra, Oracle Corporation <ashokmalhotra@alum.mit.edu>

This document is also available in these non-normative formats: XML, XHTML with changes since version 1.0 marked, XHTML with changes since previous Working Draft marked, Independent copy of the schema for schema documents, A schema for built-in datatypes only, in a separate namespace, Independent copy of the DTD for schema documents, and List of translations.


Abstract

XML Schema: Datatypes is part 2 of the specification of the XML Schema language. It defines facilities for defining datatypes to be used in XML Schemas as well as other XML specifications. The datatype language, which is itself represented in XML 1.0, provides a superset of the capabilities found in XML 1.0 document type definitions (DTDs) for specifying datatypes on elements and attributes.

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

This is a Public Working Draft of XML Schema 1.1W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes. It is here made available for review by W3C members and the public. It is intended to give an indication of the W3C XML Schema Working Group's intentions for this new version of the XML Schema language and our progress in achieving them. It attempts to be complete in indicating what will change from version 1.0, but does not specify in all cases how things will change. This version of this document was created on 30 January 2009.

For those primarily interested in the changes since version 1.0, the Changes since version 1.0 (§K) appendix, which summarizes both changes already made and also those in prospect, with links to the relevant sections of this draft, is the recommended starting point. An accompanying version of this document displays in color all changes to normative text since version 1.0; another shows changes since the previous Working Draft.

The major changes since version 1.0 include:

Changes since the previous public Working Draft include the following:

Comments on this document should be made in W3C's public installation of Bugzilla, specifying "XML Schema" as the product. Instructions can be found at http://www.w3.org/XML/2006/01/public-bugzilla. If access to Bugzilla is not feasible, please send your comments to the W3C XML Schema comments mailing list, www-xml-schema-comments@w3.org (archive) and note explicitly that you have not made a Bugzilla entry for the comment. Each Bugzilla entry and email message should contain only one comment.

The end of the Last Call review period is 20 February 2009; comments received after that date will be considered if time allows, but no guarantees can be offered.

Although feedback based on any aspect of this specification is welcome, there are certain aspects of the design presented herein for which the Working Group is particularly interested in feedback. These are designated 'priority feedback' aspects of the design, and identified as such in editorial notes at appropriate points in this draft.

Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

This document has been produced by the W3C XML Schema Working Group as part of the W3C XML Activity. The goals of the XML Schema language version 1.1 are discussed in the Requirements for XML Schema 1.1 document. The authors of this document are the members of the XML Schema Working Group. Different parts of this specification have different editors.

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. The Working Group maintains a public list of any patent disclosures made in connection with this documentthe deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) with respect to this specification must disclose the information in accordance with section 6 of the W3C Patent Policy.

The English version of this specification is the only normative version. Information about translations of this document is available at http://www.w3.org/2003/03/Translations/byTechnology?technology=xmlschema.

The presentation of this document has been augmented to identify changes from a previous version, controlled by dg-statusquo-color-1.0.xml, which shows differences from version 1.0 of this specification. Three kinds of changes are highlighted: new, added text, changed text, and deleted text.


Table of Contents

1 Introduction
    1.1 Introduction to Version 1.1
    1.2 Purpose
    1.3 Dependencies on Other Specifications
    1.4 Requirements
    1.5 Scope
    1.6 Terminology
    1.7 Constraints and Contributions
2 TypeDatatype System
    2.1 Datatype
    2.2 Value space
    2.3 Lexical space
    2.4 The Lexical Space and Lexical Mapping
    2.5 Facets
    2.6 Datatype dichotomiesDistinctions
3 Built-in datatypesBuilt-in Datatypes and Their Definitions
    3.1 Namespace considerations
    3.2 Special Built-in Datatypes
anySimpleType · anyAtomicType
    3.3 Primitive Datatypes
string · boolean · decimal · precisionDecimal · float · double · duration · dateTime · time · date · gYearMonth · gYear · gMonthDay · gDay · gMonth · hexBinary · base64Binary · anyURI · QName · NOTATION
    3.4 Derived datatypesOther Built-in Datatypes
normalizedString · token · language · NMTOKEN · NMTOKENS · Name · NCName · ID · IDREF · IDREFS · ENTITY · ENTITIES · integer · nonPositiveInteger · negativeInteger · long · int · short · byte · nonNegativeInteger · unsignedLong · unsignedInt · unsignedShort · unsignedByte · positiveInteger · yearMonthDuration · dayTimeDuration · dateTimeStamp
4 Datatype components
    4.1 Simple Type Definition
    4.2 Fundamental Facets
    4.3 Constraining Facets
5 Conformance
    5.1 Host Languages
    5.2 Independent implementations
    5.3 Conformance of data
    5.4 Partial Implementation of Infinite Datatypes

Appendices

A Schema for Schema Documents (Datatypes) Datatype Definitions (normative)
B DTD for Datatype Definitions (non-normative)
C Illustrative XML representations for the built-in simple type definitions
    C.1 Illustrative XML representations for the built-in primitive type definitions
    C.2 Illustrative XML representations for the built-in ordinary type definitions
D Built-up Value Spaces
    D.1 Numerical Values
    D.2 Date/time Values
E Function Definitions
    E.1 Generic Number-related Functions
    E.2 Duration-related Definitions
    E.3 Date/time-related Definitions
    E.4 Lexical and Canonical Mappings for Other Datatypes
F Datatypes and Facets
    F.1 Fundamental Facets
G ISO 8601 Date and Time Formats
    G.1 ISO 8601 Conventions
    G.2 Truncated and Reduced Formats
    G.3 Deviations from ISO 8601 Formats
H Adding durations to dateTimes
    H.1 Algorithm
    H.2 Commutativity and Associativity
I Regular Expressions
    I.1 Character Classes
J Implementation-defined and implementation-dependent features (normative)
    J.1 Implementation-defined features
    J.2 Implementation-dependent features
K Changes since version 1.0
    K.1 Datatypes and Facets
    K.2 Numerical Datatypes
    K.3 Date/time Datatypes
    K.4 Other changes
L Glossary (non-normative)
M References
    M.1 Normative
    M.2 Non-normative
N Acknowledgements (non-normative)

1 Introduction

next sub-section1.1 Introduction to Version 1.1

The Working Group has two main goals for this version of W3C XML Schema:

  • Significant improvements in simplicity of design and clarity of exposition without loss of backward or forward compatibility;
  • Provision of support for versioning of XML languages defined using the XML Schema specification, including the XML transfer syntax for schemas itself.

These goals are slightly in tension with one another -- the following summarizes the Working Group's strategic guidelines for changes between versions 1.0 and 1.1:

  1. Add support for versioning (acknowledging that this may be slightly disruptive to the XML transfer syntax at the margins)
  2. Allow bug fixes (unless in specific cases we decide that the fix is too disruptive for a point release)
  3. Allow editorial changes
  4. Allow design cleanup to change behavior in edge cases
  5. Allow relatively non-disruptive changes to type hierarchy (to better support current and forthcoming international standards and W3C recommendations)
  6. Allow design cleanup to change component structure (changes to functionality restricted to edge cases)
  7. Do not allow any significant changes in functionality
  8. Do not allow any changes to XML transfer syntax except those required by version control hooks and bug fixes

The overall aim as regards compatibility is that

  • All schema documents conformant to version 1.0 of this specification should also conform to version 1.1, and should have the same validation behavior across 1.0 and 1.1 implementations (except possibly in edge cases and in the details of the resulting PSVI);
  • The vast majority of schema documents conformant to version 1.1 of this specification should also conform to version 1.0, leaving aside any incompatibilities arising from support for versioning, and when they are conformant to version 1.0 (or are made conformant by the removal of versioning information), should have the same validation behavior across 1.0 and 1.1 implementations (again except possibly in edge cases and in the details of the resulting PSVI);

previous sub-section next sub-section1.2 Purpose

The [XML] specification defines limited facilities for applying datatypes to document content in that documents may contain or refer to DTDs that assign types to elements and attributes. However, document authors, including authors of traditional documents and those transporting data in XML, often require a higher degree of type checking to ensure robustness in document understanding and data interchange.

The table below offers two typical examples of XML instances in which datatypes are implicit: the instance on the left represents a billing invoice, the instance on the right a memo or perhaps an email message in XML.

Data orientedDocument oriented
<invoice>
  <orderDate>1999-01-21</orderDate>
  <shipDate>1999-01-25</shipDate>
  <billingAddress>
   <name>Ashok Malhotra</name>
   <street>123 Microsoft Ave.</street>
   <city>Hawthorne</city>
   <state>NY</state>
   <zip>10532-0000</zip>
  </billingAddress>
  <voice>555-1234</voice>
  <fax>555-4321</fax>
</invoice>
<memo importance='high'
      date='1999-03-23'>
  <from>Paul V. Biron</from>
  <to>Ashok Malhotra</to>
  <subject>Latest draft</subject>
  <body>
    We need to discuss the latest
    draft <emph>immediately</emph>.
    Either email me at <email>
    mailto:paul.v.biron@kp.org</email>
    or call <phone>555-9876</phone>
  </body>
</memo>

The invoice contains several dates and telephone numbers, the postal abbreviation for a state (which comes from an enumerated list of sanctioned values), and a ZIP code (which takes a definable regular form).  The memo contains many of the same types of information: a date, telephone number, email address and an "importance" value (from an enumerated list, such as "low", "medium" or "high").  Applications which process invoices and memos need to raise exceptions if something that was supposed to be a date or telephone number does not conform to the rules for valid dates or telephone numbers.

In both cases, validity constraints exist on the content of the instances that are not expressible in XML DTDs.  The limited datatyping facilities in XML have prevented validating XML processors from supplying the rigorous type checking required in these situations.  The result has been that individual applications writers have had to implement type checking in an ad hoc manner.  This specification addresses the need of both document authors and applications writers for a robust, extensible datatype system for XML which could be incorporated into XML processors.  As discussed below, these datatypes could be used in other XML-related standards as well.

previous sub-section next sub-section1.3 Dependencies on Other Specifications

Other specifications on which this one depends are listed in References (§M).

This specification defines some datatypes which depend on definitions in [XML] and [Namespaces in XML]; those definitions, and therefore the datatypes based on them, vary between version 1.0 ([XML 1.0], [Namespaces in XML 1.0]) and version 1.1 ([XML], [Namespaces in XML]) of those specifications. In any given use of this specification, the choice of the 1.0 or the 1.1 definition of those datatypes is ·implementation-defined·.

Conforming implementations of this specification may provide either the 1.1-based datatypes or the 1.0-based datatypes, or both. If both are supported, the choice of which datatypes to use in a particular assessment episode should be under user control.

Note: When this specification is used to check the datatype validity of XML input, implementations may provide the heuristic of using the 1.1 datatypes if the input is labeled as XML 1.1, and using the 1.0 datatypes if the input is labeled 1.0, but this heuristic should be subject to override by users, to support cases where users wish to accept XML 1.1 input but validate it using the 1.0 datatypes, or accept XML 1.0 input and validate it using the 1.1 datatypes.

This specification makes use of the EBNF notation used in the [XML] specification. Note that some constructs of the EBNF notation used here resemble the regular-expression syntax defined in this specification (Regular Expressions (§I)), but that they are not identical: there are differences. For a fuller description of the EBNF notation, see Section 6. Notation of the [XML] specification.

previous sub-section next sub-section1.4 Requirements

The [XML Schema Requirements] document spells out concrete requirements to be fulfilled by this specification, which state that the XML Schema Language must:

  1. provide for primitive data typing, including byte, date, integer, sequence, SQL and Java primitive datatypes, etc.;
  2. define a type system that is adequate for import/export from database systems (e.g., relational, object, OLAP);
  3. distinguish requirements relating to lexical data representation vs. those governing an underlying information set;
  4. allow creation of user-defined datatypes, such as datatypes that are derived from existing datatypes and which may constrain certain of its properties (e.g., range, precision, length, format).

previous sub-section next sub-section1.5 Scope

This portion of the XML Schema Language discussesspecification defines datatypes that can be used in an XML Schema.  These datatypes can be specified for element content that would be specified as #PCDATA and attribute values of various types in a DTD.  It is the intention of this specification that it be usable outside of the context of XML Schemas for a wide range of other XML-related activities such as [XSL] and [RDF Schema].

previous sub-section next sub-section1.6 Terminology

The terminology used to describe XML Schema Datatypes is defined in the body of this specification. The terms defined in the following list are used in building those definitions and in describing the actions of a datatype processor:

[Definition:]  for compatibility
A feature of this specification included solely to ensure that schemas which use this feature remain compatible with [XML].
(Of strings or names:) Two strings or names being compared must be identical. Characters with multiple possible representations in ISO/IEC 10646 (e.g. characters with both precomposed and base+diacritic forms) match only if they have the same representation in both strings. No case folding is performed.
(Of strings and rules in the grammar:) A string matches a grammatical production if and only if it belongs to the language generated by that production.
[Definition:]  maymay
Conforming documents and processorsSchemas, schema documents, and processors are permitted to but need not behave as described.
It is recommended that schemas, schema documents, and processors behave as described, but there can be valid reasons for them not to; it is important that the full implications be understood and carefully weighed before adopting behavior at variance with the recommendation.
[Definition:]  mustmust
(Of schemas and schema documents:) Conforming documents and processors Schemas and documents are required to behave as described; otherwise they are in ·error·.
(Of processors:) Processors are required to behave as described.
Schemas, schema documents and processors are forbidden to behave as described; schemas and documents which nevertheless do so are in ·error·.
A violation of the rules of this specification; results are undefined. Conforming software ·may· detect and report an error and ·may· recover from it.
A failure of a schema or schema document to conform to the rules of this specification.
Except as otherwise specified, processors must distinguish error-free (conforming) schemas and schema documents from those with errors; if a schema used in type-validation or a schema document used in constructing a schema is in error, processors must report the fact; if more than one is in error, it is ·implementation-dependent· whether more than one is reported as being in error. If more than one of the constraints given in this specification is violated, it is ·implementation-dependent· how many of the violations, and which, are reported.
Note: Failure of an XML element or attribute to be datatype-valid against a particular datatype in a particular schema is not in itself a failure to conform to this specification and thus, for purposes of this specification, not an error.

previous sub-section 1.7 Constraints and Contributions

This specification provides three different kinds of normative statements about schema components, their representations in XML and their contribution to the schema-validation of information items:

[Definition:]   Constraint on Schemas
Constraints on the schema components themselves, i.e. conditions components ·must· satisfy to be components at all. Largely to be found in Datatype components (§4).
[Definition:]   Schema Representation Constraint
Constraints on the representation of schema components in XML.  Some but not all of these are expressed in Schema for Schema Documents (Datatypes) Datatype Definitions (normative) (§A) and DTD for Datatype Definitions (non-normative) (§B).
[Definition:]   Validation Rule
Constraints expressed by schema components which information items ·must· satisfy to be schema-valid.  Largely to be found in Datatype components (§4).

2 TypeDatatype System

This section describes the conceptual framework behind the datatype system defined in this specification.  The framework has been influenced by the [ISO 11404] standard on language-independent datatypes as well as the datatypes for [SQL] and for programming languages such as Java.

The datatypes discussed in this specification are computer representations offor the most part well known abstract concepts such as integer and date. It is not the place of this specification to thoroughly define these abstract concepts; many other publications provide excellent definitions. However, this specification will attempt to describe the abstract concepts well enough that they can be readily recognized and distinguished from other abstractions with which they may be confused.

Note: Only those operations and relations needed for schema processing are defined in this specification. Applications using these datatypes are generally expected to implement appropriate additional functions and/or relations to make the datatype generally useful.  For example, the description herein of the float datatype does not define addition or multiplication, much less all of the operations defined for that datatype in [IEEE 754-1985] on which it is based. For some datatypes (e.g. language or anyURI) defined in part by reference to other specifications which impose constraints not part of the datatypes as defined here, applications may also wish to check that values conform to the requirements given in the current version of the relevant external specification.

next sub-section2.1 Datatype

[Definition:]  In this specification, a datatype is a 3-tuple, consisting of a) a set of distinct values, called its ·value space·, b) a set of lexical representations, called its ·lexical space·, and c) a set of ·facet·s that characterize properties of the ·value space·, individual values or lexical items.

[Definition:]  In this specification, a datatype has three properties:
Note: This specification only defines the operations and relations needed for schema processing.  The choice of terminology for describing/naming the datatypes is selected to guide users and implementers in how to expand the datatype to be generally useful—i.e., how to recognize the "real world" datatypes and their variants for which the datatypes defined herein are meant to be used for data interchange.

Along with the ·lexical mapping· it is often useful to have an inverse which provides a standard ·lexical representation· for each value.  Such a ·canonical mapping· is not required for schema processing, but is described herein for the benefit of users of this specification, and other specifications which might find it useful to reference these descriptions normatively. For some datatypes, notably QName and NOTATION, the mapping from lexical representations to values is context-dependent; for these types, no ·canonical mapping· is defined.

Note: Where ·canonical mappings· are defined in this specification, they are defined for ·primitive· datatypes. When a datatype is derived using facets which directly constrain the ·value space·, then for each value eliminated from the ·value space·, the corresponding lexical representations are dropped from the lexical space. The ·canonical mapping· for such a datatype is a subset of the ·canonical mapping· for its ·primitive· type and provides a ·canonical representation· for each value remaining in the ·value space·.
The ·pattern· facet, on the other hand, and any other (·implementation-defined·) ·lexical· facets, restrict the ·lexical space· directly. When more than one lexical representation is provided for a given value, such facets may remove the ·canonical representation· while permitting a different lexical representation; in this case, the value remains in the ·value space· but has no ·canonical representation·. This specification provides no recourse in such situations. Applications are free to deal with it as they see fit.
Note: This specification sometimes uses the shorter form "type" where one might strictly speaking expect the longer form "datatype" (e.g. in the phrases "union type", "list type", "base type", "item type", etc. No systematic distinction is intended between the forms of these phrase with "type" and those with "datatype"; the two forms are used interchangeably.
The distinction between "datatype" and "simple type definition", by contrast, carries more information: the datatype is characterized by its ·value space·, ·lexical space·, ·lexical mapping·, etc., as just described, independently of the specific facets or other definitional mechanisms used in the simple type definition to describe that particular ·value space· or ·lexical space·. Different simple type definitions with different selections of facets can describe the same datatype.

previous sub-section next sub-section2.2 Value space

        2.2.1 Identity
        2.2.2 Equality
        2.2.3 Order

[Definition:]  A value space is the set of values for a given datatype. Each value in the value space of a datatype is denoted by one or more literals in its ·lexical space·.

[Definition:]  The value space of a datatype is the set of values for that datatype.  Associated with each value space are selected operations and relations necessary to permit proper schema processing.  Each value in the value space of a ·primitive· or ·ordinary· datatype is denoted by one or more character strings in its ·lexical space·, according to ·the lexical mapping·; ·special· datatypes, by contrast, may include "ineffable" values not mapped to by any lexical representation. (If the mapping is restricted during a derivation in such a way that a value has no denotation, that value is dropped from the value space.)

The value spaces of datatypes are abstractions, and are defined in Built-in datatypesBuilt-in Datatypes and Their Definitions (§3) to the extent needed to clarify them for readers.  For example, in defining the numerical datatypes, we assume some general numerical concepts such as number and integer are known.  In many cases we provide references to other documents providing more complete definitions.

Note: The value spaces and the values therein are abstractions.  This specification does not prescribe any particular internal representations that must be used when implementing these datatypes.  In some cases, there are references to other specifications which do prescribe specific internal representations; these specific internal representations must be used to comply with those other specifications, but need not be used to comply with this specification.
In addition, other applications are expected to define additional appropriate operations and/or relations on these value spaces (e.g., addition and multiplication on the various numerical datatypes' value spaces), and are permitted where appropriate to even redefine the operations and relations defined within this specification, provided that for schema processing the relations and operations used are those defined herein.
The ·value space· of a given datatype can be defined in one of the following ways:
  • defined elsewhere axiomatically from fundamental notions (intensional definition) [see ·primitive·]
  • enumerated outright from values of an already defined datatype (extensional definition) [see ·enumeration·]
  • defined by restricting the ·value space· of an already defined datatype to a particular subset with a given set of properties [see derived]
  • defined as a combination of values from one or more already defined ·value space·(s) by a specific construction procedure [see ·list· and ·union·]

·value spaces· have certain properties.  For example, they always have the property of ·cardinality·, some definition of equality and might be ·ordered·, by which individual values within the ·value space· can be compared to one another.  The properties of ·value spaces· that are recognized by this specification are defined in Fundamental facets (§2.5.1).

The relations of identity and equality are required for each value space. An order relation is specified for some value spaces, but not all. A very few datatypes have other relations or operations prescribed for the purposes of this specification.

2.2.1 Identity

The identity relation is always defined. Every value space inherently has an identity relation. Two things are identical if and only if they are actually the same thing: i.e., if there is no way whatever to tell them apart. 

Note: This does not preclude implementing datatypes by using more than one internal representation for a given value, provided no mechanism inherent in the datatype implementation (i.e., other than bit-string-preserving "casting" of the datum to a different datatype) will distinguish between the two representations.

In the identity relation defined herein, values from different ·primitive· datatypes' ·value spaces· are made artificially distinct if they might otherwise be considered identical.  For example, there is a number two in the decimal datatype and a number two in the float datatype.  In the identity relation defined herein, these two values are considered distinct.  Other applications making use of these datatypes may choose to consider values such as these identical, but for the view of ·primitive· datatypes' ·value spaces· used herein, they are distinct.

WARNING:  Care must be taken when identifying values across distinct primitive datatypes.  The ·literals· '0.1' and '0.10000000009' map to the same value in float (neither 0.1 nor 0.10000000009 is in the value space, and each literal is mapped to the nearest value, namely 0.100000001490116119384765625), but map to distinct values in decimal.

Note: Datatypes ·constructed· by ·facet-based restriction· do not create new values; they define subsets of some ·primitive· datatype's ·value space·. A consequence of this fact is that the ·literals· '+2', treated as a decimal, '+2', treated as an integer, and '+2', treated as a byte, all denote the same value. They are not only equal but identical.

Given a list A and a list B, A and B are the same list if they are the same sequence of atomic values. The necessary and sufficient conditions for this identity are that A and B have the same length and that the items of A are pairwise identical to the items of B.

Note: It is a consequence of the rule just given for list identity that there is only one empty list. An empty list declared as having ·item type· decimal and an empty list declared as having ·item type· string are not only equal but identical.

2.2.2 Equality

Each ·primitive· datatype has prescribed an equality relation for its value space.  The equality relation for most datatypes is the identity relation.  In the few cases where it is not, equality has been carefully defined so that for most operations of interest to the datatype, if two values are equal and one is substituted for the other as an argument to any of the operations, the results will always also be equal.

On the other hand, equality need not cover the entire value space of the datatype (though it usually does). In particular, NaN is not equal to itself in the precisionDecimal, float, and double datatypes.

This equality relation is used when making ·facet-based restrictions· by enumeration, when checking identity constraints (in the context of [XSD 1.1 Part 1: Structures]), when checking value constraints, and in conjunction with order when making ·facet-based restrictions· involving order, with the following exception:  When processing XPath expressions as part of XML schema-validity assessment or otherwise testing membership in the ·value space· of a datatype whose derivation involves ·assertions·, equality (like all other relations) within those expressions is interpreted using the rules of XPath ([XPath 2.0]).  All comparisons for "sameness" prescribed by this specification test for equality, not for identity.

Note: In the prior version of this specification (1.0), equality was always identity.  This has been changed to permit the datatypes defined herein to more closely match the "real world" datatypes for which they are intended to be used as transmission formats.
For example, the float datatype has an equality which is not the identity ( −0 = +0 , but they are not identical—although they were identical in the 1.0 version of this specification), and whose domain excludes one value, NaN, so that  NaN ≠ NaN .
For another example, the dateTime datatype previously lost any time-zone offset information in the ·lexical representation· as the value was converted to ·UTC·; now the time zone offset is retained and two values representing the same "moment in time" but with different remembered time zone offsets are now equal but not identical.

In the equality relation defined herein, values from different primitive data spaces are made artificially unequal even if they might otherwise be considered equal.  For example, there is a number two in the decimal datatype and a number two in the float datatype.  In the equality relation defined herein, these two values are considered unequal.  Other applications making use of these datatypes may choose to consider values such as these equal; nonetheless, in the equality relation defined herein, they are unequal.

Two lists A and B are equal if and only if they have the same length and their items are pairwise equal. A list of length one containing a value V1 and an atomic value V2 are equal if and only if V1 is equal to V2.

For the purposes of this specification, there is one equality relation for all values of all datatypes (the union of the various datatype's individual equalities, if one consider relations to be sets of ordered pairs).  The equality relation is denoted by '=' and its negation by '≠', each used as a binary infix predicate:  x = y  and  x ≠ y .  On the other hand, identity relationships are always described in words.

2.2.3 Order

For some datatypes, an order relation is prescribed for use in checking upper and lower bounds of the ·value space·.  This order may be a partial order, which means that there may be values in the ·value space· which are neither equal, less-than, nor greater-than.  Such value pairs are incomparable.  In many cases, no order is prescribed; each pair of values is either equal or ·incomparable·. [Definition:]  Two values that are neither equal, less-than, nor greater-than are incomparable. Two values that are not ·incomparable· are comparable.

The order relation is used in conjunction with equality when making ·facet-based restrictions· involving order.  This is the only use of this order relation for schema processing.  Of course, when processing XPath expressions as part of XML schema-validity assessment or otherwise testing membership in the ·value space· of a datatype whose derivation involves ·assertions·, order (like all other relations) within those expressions is interpreted using the rules of XPath ([XPath 2.0]).

In this specification, this less-than order relation is denoted by '<' (and its inverse by '>'), the weak order by '≤' (and its inverse by '≥'), and the resulting ·incomparable· relation by '<>', each used as a binary infix predicate:  x < y ,  x ≤ y ,  x > y ,  x ≥ y , and  x <> y .

Note: The weak order "less-than-or-equal" means "less-than" or "equal" and one can tell which.  For example, the duration P1M (one month) is not less-than-or-equal P31D (thirty-one days) because P1M is not less than P31D, nor is P1M equal to P31D.  Instead, P1M is ·incomparable· with P31D.)  The formal definition of order for duration (duration (§3.3.7)) ensures that this is true.

For purposes of this specification, the value spaces of primitive datatypes are disjoint, even in cases where the abstractions they represent might be thought of as having values in common.  In the order relations defined in this specification, values from different value spaces are ·incomparable·.  For example, the numbers two and three are values in both the decimal datatype and the float datatype.  In the order relation defined here, the two in the decimal datatype is not less than the three in the float datatype; the two values are incomparable.  Other applications making use of these datatypes may choose to consider values such as these comparable.

Note: Comparison of values from different ·primitive· datatypes can sometimes be an error and sometimes not, depending on context.
When made for purposes of checking an enumeration constraint, such a comparison is not in itself an error, but since no two values from different ·primitive· ·value spaces· are equal, any comparison of ·incomparable· values will invariably be false.
Specifying an upper or lower bound which is of the wrong primitive datatype (and therefore ·incomparable· with the values of the datatype it is supposed to restrict) is, by contrast, always an error. It is a consequence of the rules for ·facet-based restriction· that in conforming simple type definitions, the values of upper and lower bounds, and enumerated values, must be drawn from the value space of the ·base type·, which necessarily means from the same ·primitive· datatype.
Comparison of ·incomparable· values in the context of an XPath expression (e.g. in an assertion or in the rules for conditional type assignment) can raise a dynamic error in the evaluation of the XPath expression; see [XQuery 1.0 and XPath 2.0 Functions and Operators] for details.

previous sub-section next sub-section2.3 Lexical space

In addition to its ·value space·, each datatype also has a lexical space.

[Definition:]  A lexical space is the set of valid literals for a datatype.

For example, "100" and "1.0E2" are two different literals from the ·lexical space· of float which both denote the same value. The type system defined in this specification provides a mechanism for schema designers to control the set of values and the corresponding set of acceptable literals of those values for a datatype.

Note: The literals in the ·lexical spaces· defined in this specification have the following characteristics:
Interoperability:
The number of literals for each value has been kept small; for many datatypes there is a one-to-one mapping between literals and values. This makes it easy to exchange the values between different systems. In many cases, conversion from locale-dependent representations will be required on both the originator and the recipient side, both for computer processing and for interaction with humans.
Basic readability:
Textual, rather than binary, literals are used. This makes hand editing, debugging, and similar activities possible.
Ease of parsing and serializing:
Where possible, literals correspond to those found in common programming languages and libraries.

2.3.1 Canonical Lexical Representation

While the datatypes defined in this specification have, for the most part, a single lexical representation i.e. each value in the datatype's ·value space· is denoted by a single literal in its ·lexical space·, this is not always the case.  The example in the previous section showed two literals for the datatype float which denote the same value.  Similarly, there ·may· be several literals for one of the date or time datatypes that denote the same value using different timezone indicators.

[Definition:]  A canonical lexical representation is a set of literals from among the valid set of literals for a datatype such that there is a one-to-one mapping between literals in the canonical lexical representation and values in the ·value space·.

previous sub-section next sub-section2.4 The Lexical Space and Lexical Mapping

[Definition:]  The lexical mapping for a datatype is a prescribed relation which maps from the ·lexical space· of the datatype into its ·value space·.

[Definition:]  The lexical space of a datatype is the prescribed set of strings which ·the lexical mapping· for that datatype maps to values of that datatype.

[Definition:]  The members of the ·lexical space· are lexical representations of the values to which they are mapped.

Note: For the ·special· datatypes, the ·lexical mappings· defined here map from the ·lexical space· into, but not onto, the ·value space·. The ·value spaces· of the ·special· datatypes include "ineffable" values for which the ·lexical mappings· defined in this specification provide no lexical representation.
For the ·primitive· and ·ordinary· atomic datatypes, the ·lexical mapping· is a (total) function on the entire ·lexical space· onto (not merely into) the ·value space·: every member of the ·lexical space· maps into the ·value space·, and every value is mapped to by some member of the ·lexical space·.
For ·union· datatypes, the ·lexical mapping· is not necessarily a function, since the same ·literal· may map to different values in different member types. For ·list· datatypes, the ·lexical mapping· is a function if and only if the ·lexical mapping· of the list's ·item type· is a function.

[Definition:]  A sequence of zero or more characters in the Universal Character Set (UCS) which may or may not prove upon inspection to be a member of the ·lexical space· of a given datatype and thus a ·lexical representation· of a given value in that datatype's ·value space·, is referred to as a literal. The term is used indifferently both for character sequences which are members of a particular ·lexical space· and for those which are not.

Note: One should be aware that in the context of XML schema-validity assessment, there are ·pre-lexical· transformations of the input character string (controlled by the whiteSpace facet and any implementation-defined ·pre-lexical· facets) which result in the intended ·literal·.  Other systems utilizing this specification may or may not implement these transformations.  If they do not, then input character strings that would have been transformed into correct lexical representations, when taken "raw", may not be correct ·lexical representations·.

Should a derivation be made using a derivation mechanism that removes ·lexical representations· from the·lexical space· to the extent that one or more values cease to have any ·lexical representation·, then those values are dropped from the ·value space·.

Note: This could happen by means of a pattern or other ·lexical· facet.

Conversely, should a derivation remove values then their ·lexical representations· are dropped from the ·lexical space· unless there is a facet value whose impact is defined to cause the otherwise-dropped ·lexical representation· to be mapped to another value instead.

Note: There are currently no facets with such an impact.  There may be in the future.

For example, '100' and '1.0E2' are two different ·lexical representations· from the float datatype which both denote the same value.  The datatype system defined in this specification provides mechanisms for schema designers to control the ·value space· and the corresponding set of acceptable ·lexical representations· of those values for a datatype.

2.4.1 Canonical Mapping

While the datatypes defined in this specification often have a single ·lexical representation· for each value (i.e., each value in the datatype's ·value space· is denoted by a single ·representation· in its ·lexical space·), this is not always the case.  The example in the previous section shows two ·lexical representations· from the float datatype which denote the same value.

[Definition:]  The canonical mapping is a prescribed subset of the inverse of a ·lexical mapping· which is one-to-one and whose domain (where possible) is the entire range of the ·lexical mapping· (the ·value space·).  Thus a ·canonical mapping· selects one ·lexical representation· for each value in the ·value space·.

[Definition:]  The canonical representation of a value in the ·value space· of a datatype is the ·lexical representation· associated with that value by the datatype's ·canonical mapping·.

·Canonical mappings· are not available for datatypes whose ·lexical mappings· are context dependent (i.e., mappings for which the value of a ·lexical representation· depends on the context in which it occurs, or for which a character string may or may not be a valid ·lexical representation· similarly depending on its context)

Note: ·Canonical representations· are provided where feasible for the use of other applications; they are not required for schema processing itself.  A conforming schema processor implementation is not required to implement ·canonical mappings·.

previous sub-section next sub-section2.5 Facets

        2.5.1 Fundamental facets
        2.5.2 Constraining or Non-fundamental facets

[Definition:]  A facet is a single defining aspect of a ·value space·.  Generally speaking, each facet characterizes a ·value space· along independent axes or dimensions.

The facets of a datatype serve to distinguish those aspects of one datatype which differ from other datatypes. Rather than being defined solely in terms of a prose description the datatypes in this specification are defined in terms of the synthesis of facet values which together determine the ·value space· and properties of the datatype.

Facets are of two types: fundamental facets that define the datatype and non-fundamental or constraining facets that constrain the permitted values of a datatype.

2.5.1 Fundamental facets

[Definition:]   A fundamental facet is an abstract property which serves to semantically characterize the values in a ·value space·.

All fundamental facets are fully described in Fundamental Facets (§4.2).

2.5.2 Constraining or Non-fundamental facets

[Definition:]  A constraining facet is an optional property that can be applied to a datatype to constrain its ·value space·.

Constraining the ·value space· consequently constrains the ·lexical space·.  Adding ·constraining facets· to a ·base type· is described in Derivation by restriction (§4.1.2.1).

All constraining facets are fully described in Constraining Facets (§4.3).

previous sub-section 2.6 Datatype dichotomiesDistinctions

        2.6.1 Atomic vs. List vs. Union Datatypes
            2.6.1.1 Atomic Datatypes
            2.6.1.2 List Datatypes
            2.6.1.3 Union datatypes
        2.6.2 Special vs. Primitive vs. derived datatypesOrdinary Datatypes
            2.6.2.1 Derived by restrictionFacet-based Restriction
            2.6.2.2 Derived by listConstruction by List
            2.6.2.3 Derived by unionConstruction by Union
        2.6.3 Definition, Derivation, Restriction, and Construction
        2.6.4 Built-in vs. User-DerivedDefined Datatypes

It is useful to categorize the datatypes defined in this specification along various dimensions, forming a set of characterization dichotomiesdefining terms which can be used to characterize datatypes and the Simple Type Definitions which define them.

2.6.1 Atomic vs. List vs. Union Datatypes

The first distinction to be made is that between ·atomic·, ·list· and ·union· datatypes.

First, we distinguish ·atomic·, ·list·, and ·union· datatypes.

[Definition:]  An atomic value is an elementary value, not constructed from simpler values by any user-accessible means defined by this specification.

For example, a single token which ·matches· Nmtoken from [XML] could be the valueis in the value space of anthe ·atomic· datatype (NMTOKEN);, while a sequence of such tokens could be the value of ais in the value space of the ·list· datatype (NMTOKENS).

2.6.1.1 Atomic Datatypes

·atomic· datatypes can be either ·primitive· or derived.  The ·value space· of an ·atomic· datatype is a set of "atomic" values, which for the purposes of this specification, are not further decomposable.  The ·lexical space· of an ·atomic· datatype is a set of literals whose internal structure is specific to the datatype in question. 

An ·atomic· datatype has a ·value space· consisting of a set of "atomic" or elementary values.

Note: Atomic values are sometimes regarded, and described, as "not decomposable", but in fact the values in several datatypes defined here are described with internal structure, which is appealed to in checking whether particular values satisfy various constraints (e.g. upper and lower bounds on a datatype). Other specifications which use the datatypes defined here may define operations which attribute internal structure to values and expose or act upon that structure.

The ·lexical space· of an ·atomic· datatype is a set of ·literals· whose internal structure is specific to the datatype in question.

There is one ·special· ·atomic· datatype (anyAtomicType), and a number of ·primitive· ·atomic· datatypes which have anyAtomicType as their ·base type·.  All other ·atomic· datatypes are derived either from one of the ·primitive· ·atomic· datatypes or from another ·ordinary· ·atomic· datatype.  No ·user-defined· datatype may have anyAtomicType as its ·base type·.

2.6.1.2 List Datatypes

Several type systems (such as the one described in [ISO 11404]) treat ·list· datatypes as special cases of the more general notions of aggregate or collection datatypes.

·list··List· datatypes are always ·derived··constructed· from some other type; they are never ·primitive·. The ·value space· of a ·list· datatype is athe set of finite-length sequences of zero or more ·atomic· values where each ·atomic· value is drawn from the ·value space· of the lists's ·item type· and has a ·lexical representation· containing no whitespace. The ·lexical space· of a ·list· datatype is a set of ·literals· whose internal structureeach of which is a space-separated sequence of ·literals· of the ·atomic· datatype of the items in the ·list··item type·.

[Definition:]   The ·atomic· or ·union· datatype that participates in the definition of a ·list· datatype is known as the itemTypeitem type of that ·list· datatype.  If the ·item type· is a ·union·, each of its ·basic members· must be ·atomic·.

Example
<simpleType name='sizes'>
  <list itemType='decimal'/>
</simpleType>
<cerealSizes xsi:type='sizes'> 8 10.5 12 </cerealSizes>

A ·list· datatype can be ·derived··constructed· from an ordinary or ·primitive· ·atomic· datatype whose ·lexical space· allows spacewhitespace (such as string or anyURI) or a ·union· datatype any of whose {member type definitions}'s ·lexical space· allows space. In such a case, regardless of the input, list items will be separated at space boundaries.Since ·list· items are separated at whitespace before the ·lexical representations· of the items are mapped to values, no whitespace will ever occur in the ·lexical representation· of a ·list· item, even when the item type would in principle allow it.  For the same reason, when every possible ·lexical representation· of a given value in the ·value space· of the ·item type· includes whitespace, that value can never occur as an item in any value of the ·list· datatype.

Example
<simpleType name='listOfString'>
  <list itemType='string'/>
</simpleType>
<someElement xsi:type='listOfString'>
this is not list item 1
this is not list item 2
this is not list item 3
</someElement>
In the above example, the value of the someElement element is not a ·list· of ·length· 3; rather, it is a ·list· of ·length· 18.

For each of ·length·, ·maxLength· and ·minLength·, the unit of length is measured in number of list items.  The value of ·whiteSpace· is fixed to the value collapse.

For ·list· datatypes the ·lexical space· is composed of space-separated ·literals· of itsthe ·item type·Hence, aAny ·pattern· specified when a new datatype is derived from a ·list· datatype is matched against each literal of the ·list· datatype and not against the literals of the datatype that serves as its ·item type·applies to the members of the ·list· datatype's ·lexical space·, not to the members of the ·lexical space· of the ·item type·.  Similarly, enumerated values are compared to the entire ·list·, not to individual list items, and assertions apply to the entire ·list· too. Lists are identical if and only if they have the same length and their items are pairwise identical; they are equal if and only if they have the same length and their items are pairwise equal. And a list of length one whose item is an atomic value V1 is equal to an atomic value V2 if and only if V1 is equal to V2.

Example
<xs:simpleType name='myList'>
	<xs:list itemType='xs:integer'/>
</xs:simpleType>
<xs:simpleType name='myRestrictedList'>
	<xs:restriction base='myList'>
		<xs:pattern value='123 (\d+\s)*456'/>
	</xs:restriction>
</xs:simpleType>
<someElement xsi:type='myRestrictedList'>123 456</someElement>
<someElement xsi:type='myRestrictedList'>123 987 456</someElement>
<someElement xsi:type='myRestrictedList'>123 987 567 456</someElement>

The canonical-lexical-representation for the ·list· datatype is defined as the lexical form in which each item in the ·list· has the canonical lexical representation of its ·item type·.

The ·canonical mapping· of a ·list· datatype maps each value onto the space-separated concatenation of the ·canonical representations· of all the items in the value (in order), using the ·canonical mapping· of the ·item type·.

2.6.1.3 Union datatypes

The ·value space· and ·lexical space· of a ·union· datatype are the union of the ·value spaces· and ·lexical spaces· of its ·member types·. Union types may be defined in either of two ways. When a union type is ·constructed· by ·union·, its ·value space·, ·lexical space·, and ·lexical mapping· are the "ordered unions" of the ·value spaces·, ·lexical spaces·, and ·lexical mappings· of its ·member types·.

It will be observed that the ·lexical mapping· of a union, so defined, is not necessarily a function: a given ·literal· may map to one value or to several values of different ·primitive· datatypes, and it may be indeterminate which value is to be preferred in a particular context. When the datatypes defined here are used in the context of [XSD 1.1 Part 1: Structures], the xsi:type attribute defined by that specification in section xsi:type can be used to indicate which value a ·literal· which is the content of an element should map to. In other contexts, other rules (such as type coercion rules) may be employed to determine which value is to be used.

When a union type is defined by ·restricting· another ·union·, its ·value space·, ·lexical space·, and ·lexical mapping· are subsets of the ·value spaces·, ·lexical spaces·, and ·lexical mappings· of its ·base type·.

·Union· datatypes are always ·derived··constructed· from other datatypes; they are never ·primitive·. Currently, there are no ·built-in· ·union· datatypes.

Example
A prototypical example of a ·union· type is the maxOccurs attribute on the element element in XML Schema itself: it is a union of nonNegativeInteger and an enumeration with the single member, the string "unbounded", as shown below.
  <attributeGroup name="occurs">
    <attribute name="minOccurs" type="nonNegativeInteger"
    	use="optional" default="1"/>
    <attribute name="maxOccurs"use="optional" default="1">
      <simpleType>
        <union>
          <simpleType>
            <restriction base='nonNegativeInteger'/>
          </simpleType>
          <simpleType>
            <restriction base='string'>
              <enumeration value='unbounded'/>
            </restriction>
          </simpleType>
        </union>
      </simpleType>
    </attribute>
  </attributeGroup>

Any number (greater than 1)(zero or more) of ordinary or ·primitive· ·atomic· or ·list· ·datatype·s ·datatypes· can participate in a ·union· type.

[Definition:]   The datatypes that participate in the definition of a ·union· datatype are known as the memberTypesmember types of that ·union· datatype.

[Definition:]  The transitive membership of a ·union· is the set of its own ·member types·, and the ·member types· of its members, and so on. More formally, if U is a ·union·, then (a) its ·member types· are in the transitive membership of U, and (b) for any datatypes T1 and T2, if T1 is in the transitive membership of U and T2 is one of the ·member types· of T1, then T2 is also in the transitive membership of U.

The ·transitive membership· of a ·union· must not contain the ·union· itself, nor any datatype derived or ·constructed· from the ·union·.

[Definition:]  Those members of the ·transitive membership· of a ·union· datatype U which are themselves not ·union· datatypes are the basic members of U.

[Definition:]  If a datatype M is in the ·transitive membership· of a ·union· datatype U, but not one of U's ·member types·, then a sequence of one or more ·union· datatypes necessarily exists, such that the first is one of the ·member types· of U, each is one of the ·member types· of its predecessor in the sequence, and M is one of the ·member types· of the last in the sequence. The ·union· datatypes in this sequence are said to intervene between M and U. When U and M are given by the context, the datatypes in the sequence are referred to as the intervening unions. When M is one of the ·member types· of U, the set of intervening unions is the empty set.

[Definition:]  In a valid instance of any ·union·, the first of its members in order which accepts the instance as valid is the active member type. [Definition:]  If the ·active member type· is itself a ·union·, one of its members will be its ·active member type·, and so on, until finally a ·basic (non-union) member· is reached. That ·basic member· is the active basic member of the union.

The order in which the ·member types· are specified in the definition (that is, in the case of datatypes defined in a schema document, the order of the <simpleType> children of the <union> element, or the order of the QNames in the memberTypes memberTypes attribute) is significant. During validation, an element or attribute's value is validated against the ·member types· in the order in which they appear in the definition until a match is found.  The As noted above, the evaluation order can be overridden with the use of xsi:type.

Example
For example, given the definition below, the first instance of the <size> element validates correctly as an integer (§3.4.13), the second and third as string (§3.3.1).
  <xsd:element name='size'>
    <xsd:simpleType>
      <xsd:union>
        <xsd:simpleType>
          <xsd:restriction base='integer'/>
        </xsd:simpleType>
        <xsd:simpleType>
          <xsd:restriction base='string'/>
        </xsd:simpleType>
      </xsd:union>
    </xsd:simpleType>
  </xsd:element>
  <size>1</size>
  <size>large</size>
  <size xsi:type='xsd:string'>1</size>

The canonical-lexical-representation for a ·union· datatype is defined as the lexical form in which the values have the canonical lexical representation of the appropriate ·member types·.

The ·canonical mapping· of a ·union· datatype maps each value onto the ·canonical representation· of that value obtained using the ·canonical mapping· of the first ·member type· in whose value space it lies.

Note: A datatype which is ·atomic· in this specification need not be an "atomic" datatype in any programming language used to implement this specification.  Likewise, a datatype which is a ·list· in this specification need not be a "list" datatype in any programming language used to implement this specification. Furthermore, a datatype which is a ·union· in this specification need not be a "union" datatype in any programming language used to implement this specification.
When a datatype is derived by ·restricting· a ·union· datatype, the following ·constraining facets· apply:

2.6.2 Special vs. Primitive vs. derived datatypesOrdinary Datatypes

Next, we distinguish between ·primitive· and derived datatypes.

Next, we distinguish ·special·, ·primitive·, and ·ordinary· (or ·constructed·) datatypes.  Each datatype defined by or in accordance with this specification falls into exactly one of these categories.

For example, in this specification, float is a ·primitive· datatype based on a well-defined mathematical concept that cannot beand not defined in terms of other datatypes, while a integer is a special case of·constructed· from the more general datatype decimal.

[Definition:]  The simple ur-type definition is a special restriction of the ur-type definition whose name is anySimpleType in the XML Schema namespace.  anySimpleType can be considered as the ·base type· of all ·primitive· datatypes.  anySimpleType is considered to have an unconstrained lexical space and a ·value space· consisting of the union of the ·value spaces· of all the ·primitive· datatypes and the set of all lists of all members of the ·value spaces· of all the ·primitive· datatypes.

The datatypes defined by this specification fall into both the ·primitive· and ·derived· categories.  It is felt that a judiciously chosen set of ·primitive· datatypes will serve the widest possible audience by providing a set of convenient datatypes that can be used as is, as well as providing a rich enough base from which the variety of datatypes needed by schema designers can be ·derived·.

In the example above, integer is derived from decimal.

Note: A datatype which is ·primitive· in this specification need not be a "primitive" datatype in any programming language used to implement this specification.  Likewise, a datatype which is ·derived· in this specification need not be a "derived" datatype in any programming language used to implement this specification.

As described in more detail in XML Representation of Simple Type Definition Schema Components (§4.1.2), each ·user-derived· datatype ·must· be defined in terms of another datatype in one of three ways: 1) by assigning ·constraining facets· which serve to restrict the ·value space· of the ·user-derived· datatype to a subset of that of the ·base type·; 2) by creating a ·list· datatype whose ·value space· consists of finite-length sequences of values of its ·item type·; or 3) by creating a ·union· datatype whose ·value space· consists of the union of the ·value spaces· of its ·member types·.

2.6.2.1 Derived by restrictionFacet-based Restriction

[Definition:]  A datatype is said to be derived by restriction from another datatype when values for zero or more ·constraining facets· are specified that serve to constrain its ·value space· and/or its ·lexical space· to a subset of those of its ·base type·.

[Definition:]  A datatype is defined by facet-based restriction of another datatype (its ·base type·), when values for zero or more ·constraining facets· are specified that serve to constrain its ·value space· and/or its ·lexical space· to a subset of those of the ·base type·. The ·base type· of a ·facet-based restriction· must be a ·primitive· or ·ordinary· datatype.

[Definition:]  Every datatype that is derived by ·restriction· is defined in terms of an existing datatype, referred to as its base type. Base types can be either ·primitive· or derived.

2.6.2.2 Derived by listConstruction by List

A ·list· datatype can be ·derived··constructed· from another datatype (its ·item type·) by creating a ·value space· that consists of a finite-length sequences of zero or more values of its ·item type·. Datatypes so ·constructed· have anySimpleType as their ·base type·. Note that since the ·value space· and ·lexical space· of any ·list· datatype are necessarily subsets of the ·value space· and ·lexical space· of anySimpleType, any datatype ·constructed· as a ·list· is a ·restriction· of its base type.

2.6.2.3 Derived by unionConstruction by Union

One datatype can be ·derived··constructed· from one or more datatypes by ·union·ingunioning their ·value spaces··lexical mappings· and, consequently, their ·value spaces· and ·lexical spaces··lexical spaces·Datatypes so ·constructed· also have anySimpleType as their ·base type·. Note that since the ·value space· and ·lexical space· of any ·union· datatype are necessarily subsets of the ·value space· and ·lexical space· of anySimpleType, any datatype ·constructed· as a ·union· is a ·restriction· of its base type.

2.6.3 Definition, Derivation, Restriction, and Construction

Definition, derivation, restriction, and construction are conceptually distinct, although in practice they are frequently performed by the same mechanisms.

By 'definition' is meant the explicit identification of the relevant properties of a datatype, in particular its ·value space·, ·lexical space·, and ·lexical mapping·.

The properties of the ·special· and the standard ·primitive· datatypes are defined by this specification. A Simple Type Definition is present for each of these datatypes in every valid schema; it serves as a representation of the datatype, but by itself it does not capture all the relevant information and does not suffice (without knowledge of this specification) to define the datatype.

Note: The properties of any ·implementation-defined· ·primitive· datatypes are given not here but in the documentation for the implementation in question.

For all other datatypes, a Simple Type Definition does suffice. The properties of an ·ordinary· datatype can be inferred from the datatype's Simple Type Definition and the properties of the ·base type·, ·item type· if any, and ·member types· if any. All ·ordinary· datatypes can be defined in this way.

By 'derivation' is meant the relation of a datatype to its ·base type·, or to the ·base type· of its ·base type·, and so on.

[Definition:]  Every datatype other than anySimpleType is associated with another datatype, its base type. Base types can be ·special·, ·primitive·, or ·ordinary·.

[Definition:]  A datatype T is immediately derived from another datatype X if and only if X is the ·base type· of T.

Note: The above does not preclude the Simple Type Definition for anySimpleType from having a value for its {base type definition}.  (It does, and its value is anyType.)
More generally,
[Definition:]  A datatype R is derived from another datatype B if and only if one of the following is true:

A datatype must not be derived from itself. That is, the base type relation must be acyclic.

It is a consequence of the above that every datatype other than anySimpleType is derived from anySimpleType.

Since each datatype has exactly one ·base type·, and every datatype other than anySimpleType is derived directly or indirectly from anySimpleType, it follows that the ·base type· relation arranges all simple types into a tree structure, which is conventionally referred to as the derivation hierarchy.

By 'restriction' is meant the definition of a datatype whose ·value space· and ·lexical space· are subsets of those of its ·base type·.

Formally, [Definition:]  A datatype R is a restriction of another datatype B when

Note that all three forms of datatype ·construction· produce ·restrictions· of the ·base type·: ·facet-based restriction· does so by means of ·constraining facets·, while ·construction· by ·list· or ·union· does so because those ·constructions· take anySimpleType as the ·base type·. It follows that all datatypes are ·restrictions· of anySimpleType. This specification provides no means by which a datatype may be defined so as to have a larger ·lexical space· or ·value space· than its ·base type·.

By 'construction' is meant the creation of a datatype by defining it in terms of another.

[Definition:]  All ·ordinary· datatypes are defined in terms of, or constructed from, other datatypes, either by ·restricting· the ·value space· or ·lexical space· of a ·base type· using zero or more ·constraining facets· or by specifying the new datatype as a ·list· of items of some ·item type·, or by defining it as a ·union· of some specified sequence of ·member types·. These three forms of ·construction· are often called "·facet-based restriction·", "·construction· by ·list·", and "·construction· by ·union·", respectively. Datatypes so constructed may be understood fully (for purposes of a type system) in terms of (a) the properties of the datatype(s) from which they are constructed, and (b) their Simple Type Definition. This distinguishes ·ordinary· datatypes from the ·special· and ·primitive· datatypes, which can be understood only in the light of documentation (namely, their descriptions elsewhere in this specification, or, for ·implementation-defined· ·primitives·, in the appropriate implementation-specific documentation). All ·ordinary· datatypes are ·constructed·, and all ·constructed· datatypes are ·ordinary·.

2.6.4 Built-in vs. User-DerivedDefined Datatypes

The ·built-in· datatypes are intended to be available automatically whenever this specification is implemented or used, whether by itself or embedded in a host language. In the language defined by [XSD 1.1 Part 1: Structures], the ·built-in· datatypes are automatically included in every valid schema. Other host languages should specify that all of the datatypes decribed here as built-ins are automatically available; they may specify that additional datatypes are also made available automatically.

Note: ·Implementation-defined· datatypes, whether ·primitive· or ·ordinary·, may sometimes be included automatically in any schemas processed by that implementation; nevertheless, they are not built in to every schema, and are thus not included in the term 'built-in', as that term is used in this specification.

The mechanism for making ·user-defined· datatypes available for use is not defined in this specification; if ·user-defined· datatypes are to be available, some such mechanism must be specified by the host language.

[Definition:]  A datatype which is not available for use is said to be unknown.

Note: From the schema author's perspective, a reference to a datatype which proves to be ·unknown· might reflect any of the following causes, or others:
1 An error has been made in giving the name of the datatype.
2 The datatype is a ·user-defined· datatype which has not been made available using the means defined by the host language (e.g. because the appropriate schema document has not been consulted).
3 The datatype is an ·implementation-defined· ·primitive· datatype not supported by the implementation being used.
4 The datatype is an ·implementation-defined· ·ordinary· datatype which is made automatically available by some implementations, but not by the implementation being used.
5 The datatype is a ·user-defined· ·ordinary· datatype whose base type is ·unknown·
From the point of view of the implementation, these cases are likely to be indistinguishable.
Note: In the terminology of [XSD 1.1 Part 1: Structures], the datatypes here called ·unknown· are referred to as absent.

Conceptually there is no difference between the ·ordinary· ·built-in· ·derived· datatypes included in this specification and the ·user-derived··user-defined· datatypes which will be created by individual schema designers. The ·built-in· ·derived··constructed· datatypes are those which are believed to be so common that if they were not defined in this specification many schema designers would end up "reinventing"reinventing them.  Furthermore, including these ·derived··constructed· datatypes in this specification serves to demonstrate the mechanics and utility of the datatype generation facilities of this specification.

Note: A datatype which is ·built-in· in this specification need not be a "built-in" datatype in any programming language used to implement this specification.  Likewise, a datatype which is ·user-derived· in this specification need not be a "user-derived" datatype in any programming language used to implement this specification.

3 Built-in datatypesBuilt-in Datatypes and Their Definitions

Built-in Datatype Hierarchy diagram
Built-in Datatype Hierarchy diagram
anyType anyType anySimpleType anySimpleType string string precisionDecimal precisionDecimal hexBinary hexBinary anyAtomicType anyAtomicType ENTITY ENTITY ENTITIES ENTITIES ID ID IDREFS IDREFS IDREF IDREF Name Name NCName NCName NMTOKEN NMTOKEN NMTOKENS NMTOKENS language language token token normalizedString normalizedString float float double double unsignedByte unsignedByte unsignedShort unsignedShort unsignedInt unsignedInt unsignedLong unsignedLong positiveInteger positiveInteger byte byte short short int int negativeInteger negativeInteger nonPositiveInteger nonPositiveInteger long long nonNegativeInteger nonNegativeInteger integer integer decimal decimal gMonth gMonth gDay gDay gMonthDay gMonthDay gYear gYear gYearMonth gYearMonth date date time time dateTime dateTime duration duration NOTATION NOTATION QName QName anyURI anyURI base64Binary base64Binary boolean boolean
anyType all complex types anySimpleType anyAtomicType anyURI base64Binary boolean date dateTime dateTimeStamp decimal integer long int short byte nonNegativeInteger positiveInteger unsignedLong unsignedInt unsignedShort unsignedByte nonPositiveInteger negativeInteger double duration dayTimeDuration yearMonthDuration float gDay gMonth gMonthDay gYear gYearMonth hexBinary NOTATION precisionDecimal QName string normalizedString token language Name NCName ENTITY ID IDREF NMTOKEN time ENTITIES IDREFS NMTOKENS
Each built-in datatype defined in this specification (both ·primitive· and derived) can be uniquely addressed via a URI Reference constructed as follows:
  1. the base URI is the URI of the XML Schema namespace
  2. the fragment identifier is the name of the datatype
For example, to address the int datatype, the URI is:
  • http://www.w3.org/2001/XMLSchema#int
Additionally, each facet definition element can be uniquely addressed via a URI constructed as follows:
  1. the base URI is the URI of the XML Schema namespace
  2. the fragment identifier is the name of the facet
For example, to address the maxInclusive facet, the URI is:
  • http://www.w3.org/2001/XMLSchema#maxInclusive
Additionally, each facet usage in a built-in datatype definition Simple Type Definition can be uniquely addressed via a URI constructed as follows:
  1. the base URI is the URI of the XML Schema namespace
  2. the fragment identifier is the name of the datatypeSimple Type Definition, followed by a period ('.') followed by the name of the facet
For example, to address the usage of the maxInclusive facet in the definition of int, the URI is:
  • http://www.w3.org/2001/XMLSchema#int.maxInclusive

next sub-section3.1 Namespace considerations

The ·built-in· datatypes defined by this specification are designed to be used with the XML Schema definition language as well as other XML specifications. To facilitate usage within the XML Schema definition language, the ·built-in· datatypes in this specification have the namespace name:

  • http://www.w3.org/2001/XMLSchema

To facilitate usage in specifications other than the XML Schema definition language, such as those that do not want to know anything about aspects of the XML Schema definition language other than the datatypes, each non-·special· ·built-in· datatype is also defined in the namespace whose URI is:

  • http://www.w3.org/2001/XMLSchema-datatypes

This applies to both ·built-in· ·primitive· and ·built-in· derived datatypes.

Note: The use of the XMLSchema-datatypes namespace and the definitions therein are deprecated as of XML Schema 1.1.

Each ·user-derived··user-defined· datatype is alsomay also be associated with a uniquetarget namespace.  However, ·user-derived· datatypes do not come from the namespace defined by this specification; rather, they come from the namespace of the schema in which they are defined (seeIf it is constructed from a schema document, then its namespace is typically the target namespace of that schema document. (See XML Representation of Schemas in [XSD 1.1 Part 1: Structures])..)

previous sub-section next sub-section3.2 Special Built-in Datatypes

        3.2.1 anySimpleType
            3.2.1.1 Value space
            3.2.1.2 Lexical mapping
            3.2.1.3 Facets
        3.2.2 anyAtomicType
            3.2.2.1 Value space
            3.2.2.2 Lexical mapping
            3.2.2.3 Facets

The two datatypes at the root of the hierarchy of simple types are anySimpleType and anyAtomicType.

3.2.1 anySimpleType

[Definition:]   The definition of anySimpleType is a special ·restriction· of anyType.  Its ·lexical space· is the set of all sequences of Unicode characters, and its ·value space· includes all ·atomic values· and all finite-length lists of zero or more ·atomic values·.

For further details of anySimpleType and its representation as a Simple Type Definition, see Built-in Simple Type Definitions (§4.1.7).

3.2.1.1 Value space

The ·value space· of anySimpleType is the set of all ·atomic values· and of all finite-length lists of zero or more ·atomic values·.

Note: It is a consequence of this definition, together with the definition of the ·lexical mapping· in the next section, that some values of this datatype have no ·lexical representation· using the ·lexical mappings· defined by this specification. That is, the "potential" ·value space· and the "effable" or "nameable" ·value space· diverge for this datatype. As far as this specification is concerned, there is no operational difference between the potential and effable ·value spaces· and the distinction is of mostly formal interest. Since some host languages for the type system defined here may allow means of construction values other than mapping from a ·lexical representation·, the difference may have practical importance in some contexts. In those contexts, the term ·value space· should unless otherwise qualified be taken to mean the potential ·value space·.
3.2.1.2 Lexical mapping

The ·lexical space· of anySimpleType is the set of all finite-length sequences of zero or more characters (as defined in [XML]) that ·match· the Char production from [XML]. This is equivalent to the union of the ·lexical spaces· of all ·primitive· and all possible ·ordinary· datatypes.

It is ·implementation-defined· whether an implementation of this specification supports the Char production from [XML], or that from [XML 1.0], or both. See Dependencies on Other Specifications (§1.3).

The ·lexical mapping· of anySimpleType is the union of the ·lexical mappings· of all ·primitive· datatypes and all list datatypes. It will be noted that this mapping is not a function: a given ·literal· may map to one value or to several values of different ·primitive· datatypes, and it may be indeterminate which value is to be preferred in a particular context. When the datatypes defined here are used in the context of [XSD 1.1 Part 1: Structures], the xsi:type attribute defined by that specification in section xsi:type can be used to indicate which value a ·literal· which is the content of an element should map to. In other contexts, other rules (such as type coercion rules) may be employed to determine which value is to be used.

3.2.1.3 Facets

When a new datatype is defined by ·facet-based restriction·, anySimpleType must not be used as the ·base type·. So no ·constraining facets· are directly applicable to anySimpleType.

3.2.2 anyAtomicType

[Definition:]   anyAtomicType is a special ·restriction· of anySimpleType. The ·value· and ·lexical spaces· of anyAtomicType are the unions of the ·value· and ·lexical spaces· of all the ·primitive· datatypes, and anyAtomicType is their ·base type·.

For further details of anyAtomicType and its representation as a Simple Type Definition, see Built-in Simple Type Definitions (§4.1.7).

3.2.2.1 Value space

The ·value space· of anyAtomicType is the union of the ·value spaces· of all the ·primitive· datatypes defined here or supplied as ·implementation-defined· ·primitives·.

3.2.2.2 Lexical mapping

The ·lexical space· of anyAtomicType is the set of all finite-length sequences of zero or more characters (as defined in [XML]) that ·match· the Char production from [XML]. This is equivalent to the union of the ·lexical spaces· of all ·primitive· datatypes.

It is ·implementation-defined· whether an implementation of this specification supports the Char production from [XML], or that from [XML 1.0], or both. See Dependencies on Other Specifications (§1.3).

The ·lexical mapping· of anyAtomicType is the union of the ·lexical mappings· of all ·primitive· datatypes. It will be noted that this mapping is not a function: a given ·literal· may map to one value or to several values of different ·primitive· datatypes, and it may be indeterminate which value is to be preferred in a particular context. When the datatypes defined here are used in the context of [XSD 1.1 Part 1: Structures], the xsi:type attribute defined by that specification in section xsi:type can be used to indicate which value a ·literal· which is the content of an element should map to. In other contexts, other rules (such as type coercion rules) may be employed to determine which value is to be used.

3.2.2.3 Facets

When a new datatype is defined by ·facet-based restriction·, anyAtomicType must not be used as the ·base type·. So no ·constraining facets· are directly applicable to anyAtomicType.

previous sub-section next sub-section3.3 Primitive Datatypes

        3.3.1 string
            3.3.1.1 Value Space
            3.3.1.2 Lexical Mapping
            3.3.1.3 Constraining facets Facets
            3.3.1.4 Derived datatypes
        3.3.2 boolean
            3.3.2.1 Value Space
            3.3.2.2 Lexical representation
            3.3.2.3 Canonical representation
            3.3.2.4 Lexical Mapping
            3.3.2.5 Constraining facets Facets
        3.3.3 decimal
            3.3.3.1 Lexical representationMapping
            3.3.3.2 Canonical representation
            3.3.3.3 Constraining facets Facets
            3.3.3.4 Derived datatypesDatatypes based on decimal
        3.3.4 precisionDecimal
            3.3.4.1 Value Space
            3.3.4.2 Lexical Mapping
            3.3.4.3 Facets
        3.3.5 float
            3.3.5.1 Value Space
            3.3.5.2 Lexical representation
            3.3.5.3 Canonical representation
            3.3.5.4 Lexical Mapping
            3.3.5.5 Constraining facets Facets
        3.3.6 double
            3.3.6.1 Value Space
            3.3.6.2 Lexical representation
            3.3.6.3 Canonical representation
            3.3.6.4 Lexical Mapping
            3.3.6.5 Constraining facets Facets
        3.3.7 duration
            3.3.7.1 Value Space
            3.3.7.2 Lexical representation
            3.3.7.3 Lexical Mapping
            3.3.7.4 Order relation on duration
            3.3.7.5 Facet Comparison for durations
            3.3.7.6 Totally ordered durations
            3.3.7.7 constraining facets Facets
            3.3.7.8 Related Datatypes
        3.3.8 dateTime
            3.3.8.1 Value Space
            3.3.8.2 Lexical representation
            3.3.8.3 Canonical representation
            3.3.8.4 Lexical Mapping
            3.3.8.5 Timezones
            3.3.8.6 Order relation on dateTime
            3.3.8.7 Totally ordered dateTimes
            3.3.8.8 Constraining facets Facets
            3.3.8.9 Related Datatypes
        3.3.9 time
            3.3.9.1 Value Space
            3.3.9.2 Lexical representation
            3.3.9.3 Canonical representation
            3.3.9.4 Lexical Mappings
            3.3.9.5 Constraining facets Facets
        3.3.10 date
            3.3.10.1 Value Space
            3.3.10.2 Lexical representation
            3.3.10.3 Canonical representation
            3.3.10.4 Lexical Mapping
            3.3.10.5 Facets
        3.3.11 gYearMonth
            3.3.11.1 Value Space
            3.3.11.2 Lexical representationMapping
            3.3.11.3 Constraining facets Facets
        3.3.12 gYear
            3.3.12.1 Value Space
            3.3.12.2 Lexical representationMapping
            3.3.12.3 Constraining facets Facets
        3.3.13 gMonthDay
            3.3.13.1 Value Space
            3.3.13.2 Lexical representationMapping
            3.3.13.3 Constraining facets Facets
        3.3.14 gDay
            3.3.14.1 Value Space
            3.3.14.2 Lexical representation
            3.3.14.3 Lexical Mapping
            3.3.14.4 constraining facets Facets
        3.3.15 gMonth
            3.3.15.1 Value Space
            3.3.15.2 Lexical representationMapping
            3.3.15.3 Constraining facets Facets
        3.3.16 hexBinary
            3.3.16.1 Value Space
            3.3.16.2 Lexical RepresentationMapping
            3.3.16.3 Canonical Representation
            3.3.16.4 Constraining facets Facets
        3.3.17 base64Binary
            3.3.17.1 Value Space
            3.3.17.2 Lexical Mapping
            3.3.17.3 Constraining facets Facets
        3.3.18 anyURI
            3.3.18.1 Lexical representationMapping
            3.3.18.2 Constraining facets Facets
        3.3.19 QName
            3.3.19.1 Constraining facets Facets
        3.3.20 NOTATION
            3.3.20.1 Constraining facets Facets

The ·primitive· datatypes defined by this specification are described below.  For each datatype, the ·value space· is described; and the ·lexical space· areis defined, using an extended Backus Naur Format grammar (and in most cases also a regular expression using the regular expression language of Regular Expressions (§I)); ·constraining facets· which apply to the datatype are listed; and any datatypes ·derived··constructed· from this datatype are specified.

Conforming processors must support the ·primitive· datatypes defined in this specification; it is ·implementation-defined· whether they support others. ·primitive··Primitive· datatypes can onlymay be added by revisions to this specification.

3.3.1 string

[Definition:]  The string datatype represents character strings in XML.  The ·value space· of string is the set of finite-length sequences of characters (as defined in [XML]) that ·match· the Char production from [XML]. A character is an atomic unit of communication; it is not further specified except to note that every character has a corresponding Universal Character Set code point, which is an integer.

Note: Many human languages have writing systems that require child elements for control of aspects such as bidirectional formatting or ruby annotation (see [Ruby] and Section 8.2.4 Overriding the bidirectional algorithm: the BDO element of [HTML 4.01]).  Thus, stringstring, as a simple type that can contain only characters but not child elements, is often not suitable for representing text. In such situations, a complex type that allows mixed content should be considered. For more information, see Section 5.5 Any Element, Any Attribute of [XML Schema Language: Part 0 Primer].
3.3.1.1 Value Space

The ·value space· of string is the set of finite-length sequences of zero or more characters (as defined in [XML]) that ·match· the Char production from [XML]. A character is an atomic unit of communication; it is not further specified except to note that every character has a corresponding Universal Character Set (UCS) code point, which is an integer.

It is ·implementation-defined· whether an implementation of this specification supports the Char production from [XML], or that from [XML 1.0], or both. See Dependencies on Other Specifications (§1.3).

Equality for string is identity. No order is prescribed.

Note: As noted in ordered, the fact that this specification does not specify an ·order-relation·order relation for ·string· does not preclude other applications from treating strings as being ordered.
3.3.1.2 Lexical Mapping
The ·lexical space· of string is the set of finite-length sequences of zero or more characters (as defined in [XML]) that ·match· the Char production from [XML].
Lexical Space
stringRep ::= Char
/* (as defined in [XML]) */

It is ·implementation-defined· whether an implementation of this specification supports the Char production from [XML], or that from [XML 1.0], or both. See Dependencies on Other Specifications (§1.3).

The ·lexical mapping· for string is ·stringLexicalMap·, and the ·canonical mapping· is ·stringCanonicalMap·; each is a subset of the identity function.

3.3.1.3 Constraining facets Facets

string has the following ·constraining facets·:

string has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from string may also specify values for the following ·constraining facets·:

string has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false
3.3.1.4 Derived datatypes

The following ·built-in· datatype is ·derived· from string

3.3.2 boolean

[Definition:]  boolean has the ·value space· required to support the mathematical concept of binary-valued logic: {true, false}represents the values of two-valued logic.

3.3.2.1 Value Space

boolean has the ·value space· of two-valued logic:  {true, false}.

3.3.2.2 Lexical representation

An instance of a datatype that is defined as ·boolean· can have the following legal literals {true, false, 1, 0}.

3.3.2.3 Canonical representation

The ·canonical representation· for boolean is the set of literals {true, false}.

3.3.2.4 Lexical Mapping
boolean's lexical space is a set of four ·literals·:
Lexical Space
booleanRep ::= 'true' | 'false' | '1' | '0'

The ·lexical mapping· for boolean is ·booleanLexicalMap·; the ·canonical mapping· is ·booleanCanonicalMap·.

3.3.2.5 Constraining facets Facets

boolean has the following ·constraining facets·:

boolean and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

Datatypes derived by restriction from boolean may also specify values for the following ·constraining facets·:

boolean has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = finite
  • numeric = false

3.3.3 decimal

[Definition:]  decimal represents a subset of the real numbers, which can be represented by decimal numerals. The ·value space· of decimal is the set of numbers that can be obtained by multiplyingdividing an integer by a non-positivenegative power of ten, i.e., expressible as i × 10^-ni / 10n where i and n are integers and n >= 0n ≥ 0. Precision is not reflected in this value space; the number 2.0 is not distinct from the number 2.00. (The datatype precisionDecimal may be used for values in which precision is significant.) The ·order-relation·order relation on decimal is the order relation on real numbers, restricted to this subset.

Note: All ·minimally conforming· processors ·must· support decimal numbers with a minimum of 18 decimal digits (i.e., with a ·totalDigits· of 18).  However, ·minimally conforming· processors ·may· set an application-defined limit on the maximum number of decimal digits they are prepared to support, in which case that application-defined maximum number ·must· be clearly documented.
3.3.3.1 Lexical representationMapping

decimal has a lexical representation consisting of a non-empty finite-length sequence of decimal digits (#x30–#x39) separated by a period as a decimal indicator.  An optional leading sign is allowed.  If the sign is omitted, "+" is assumed.  Leading and trailing zeroes are optional.  If the fractional part is zero, the period and following zero(es) can be omitted. For example:  -1.23, 12678967.543233, +100000.00, 210'-1.23', '12678967.543233', '+100000.00', '210'.

The decimal Lexical Representation
decimalLexicalRep ::= decimalPtNumeral | noDecimalPtNumeral
The lexical space of decimal is the set of lexical representations which match the grammar given above, or (equivalently) the regular expression

(\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)

The mapping from lexical representations to values is the usual one for decimal numerals; it is given formally in:
Lexical Mapping
Maps a decimalLexicalRep onto a decimal value.

The mapping from lexical representations to values is the usual one for decimal numerals; it is given formally in ·decimalLexicalMap·.

The definition of the ·canonical representation· has the effect of prohibiting certain options from the Lexical representationMapping (§3.3.3.1).  Specifically, for integers, the decimal point and fractional part are prohibited. For other values, the preceding optional "+" sign is prohibited.  The decimal point is required.  In all cases, leading and trailing zeroes are prohibited subject to the following:  there must be at least one digit to the right and to the left of the decimal point which may be a zero.

The mapping from values to ·canonical representations· is given formally in ·decimalCanonicalMap·.

3.3.3.2 Canonical representation

The ·canonical representation· for decimal is defined by prohibiting certain options from the Lexical representationMapping (§3.3.3.1).  Specifically, the preceding optional "+" sign is prohibited.  The decimal point is required.  Leading and trailing zeroes are prohibited subject to the following:  there must be at least one digit to the right and to the left of the decimal point which may be a zero.

The mapping from values to ·canonical representations· is given formally in:
3.3.3.3 Constraining facets Facets

decimal has the following ·constraining facets·:

decimal and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

Datatypes derived by restriction from decimal may also specify values for the following ·constraining facets·:

decimal has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = false
  • cardinality = countably infinite
  • numeric = true
3.3.3.4 Derived datatypesDatatypes based on decimal

The following ·built-in· datatype is ·derived· from decimal

3.3.4 precisionDecimal

[Definition:]  The precisionDecimal datatype represents the numeric value and (arithmetic) precision of decimal numbers which retain precision; it also includes values for positive and negative infinity and for "not a number", and it differentiates between "positive zero" and "negative zero".  This datatype is introduced to provide a variant of decimal that closely corresponds to the floating-point decimal datatypes described by the expected forthcoming revision of IEEE/ANSI 754. Precision of values is retained and values are included for two zeroes, two infinities, and not-a-number.

Precision is sometimes given in absolute, sometimes in relative terms. [Definition:]  The arithmetic precision of a value is expressed in absolute quantitative terms, by indicating how many digits to the right of the decimal point are significant. "5" has an arithmetic precision of 0, and "5.01" an arithmetic precision of 2.

Note: See the conformance note in Partial Implementation of Infinite Datatypes (§5.4), which applies to this datatype.
3.3.4.1 Value Space
Properties of precisionDecimal Values
a decimal number, positiveInfinity, negativeInfinity or notANumber
an integer or absent; absent if and only if ·numericalValue· is a ·special value·.
positive, negative, or absent; must be positive if ·numericalValue· is positive or positiveInfinity, must be negative if ·numericalValue· is negative or negativeInfinity, must be absent if and only if ·numericalValue· is notANumber
Note: The ·sign· property is redundant except when ·numericalValue· is zero; in other cases, the ·sign· value is fully determined by the ·numericalValue· value.
Note: As explained below, 'NaN' is the lexical representation of the precisionDecimal value whose ·numericalValue· property has the ·special value· notANumber.  Accordingly, in English text we use 'NaN' to refer to that value.  Similarly we use 'INF' and '−INF' to refer to the two values whose ·numericalValue· properties have the ·special values· positiveInfinity and negativeInfinity.  These three precisionDecimal values are also informally called "not-a-number", "positive infinity", and "negative infinity". The latter two together are called "the infinities".
Equality and order for precisionDecimal are defined as follows:
  • Two numerical precisionDecimal values are ordered (or equal) as their ·numericalValue· values are ordered (or equal).  (This means that two zeroes with different ·sign·s are equal; negative zeroes are not ordered less than positive zeroes.)
  • INF is equal only to itself, and is greater than −INF and all numerical precisionDecimal values.
  • −INF is equal only to itself, and is less than INF and all numerical precisionDecimal values.
  • NaN is incomparable with all values, including itself.
Note: Any value ·incomparable· with the value used for the four bounding facets (·minInclusive·, ·maxInclusive·, ·minExclusive·, and ·maxExclusive·) will be excluded from the resulting restricted ·value space·.  In particular, when NaN is used as a facet value for a bounding facet, since no float values are ·comparable· with it, the result is a ·value space· that is empty.  If any other value is used for a bounding facet, NaN will be excluded from the resulting restricted ·value space·; to add NaN back in requires union with the NaN-only space (which may be derived using a pattern).
Note: As specified elsewhere, enumerations test values for equality with one of the enumerated values. Because NaN ≠ NaN, including NaN in an enumeration does not have the effect of accepting NaNs as instances of the enumerated type; a union with a NaN-only datatype (which may be derived using the pattern "NaN") can be used instead.
3.3.4.2 Lexical Mapping
precisionDecimal's lexical space is the set of all decimal numerals with or without a decimal point, numerals in scientific (exponential) notation, and the character strings 'INF', '+INF', '-INF', and 'NaN'.
The pDecimalRep production is equivalent (after whitespace is removed) to the following regular expression:

(\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)([Ee](\+|-)?[0-9]+)?
|(\+|-)?INF|NaN

The ·lexical mapping· for precisionDecimal is ·precisionDecimalLexicalMap·. The ·canonical mapping· is ·precisionDecimalCanonicalMap·.

3.3.4.3 Facets

precisionDecimal has the following ·constraining facets·:

precisionDecimal and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

Datatypes derived by restriction from precisionDecimal may also specify values for the following ·constraining facets·:

precisionDecimal has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = false
  • cardinality = countably infinite
  • numeric = true

3.3.5 float

[Definition:]  The float datatype is patterned after patterned after the IEEE single-precision 32-bit floating point datatype [IEEE 754-1985].  The basic ·value space· of float consists of the values m × 2^e, where m is an integer whose absolute value is less than 2^24, and e is an integer between -149 and 104, inclusive.  In addition to the basic ·value space· described above, the ·value space· of float also contains the following three special values: positive and negative infinity and not-a-number (NaN).  The ·order-relation· on float is: x < y iff y - x is positive for x and y in the value space. Positive infinity is greater than all other non-NaN values. NaN equals itself but is incomparable with (neither greater than nor less than) any other value in the ·value space·.   Its value space is a subset of the rational numbers.  Floating point numbers are often used to approximate arbitrary real numbers.

Note: "Equality" in this Recommendation is defined to be "identity" (i.e., values that are identical in the ·value space· are equal and vice versa). Identity must be used for the few operations that are defined in this Recommendation. Applications using any of the datatypes defined in this Recommendation may use different definitions of equality for computational purposes; [IEEE 754-1985]-based computation systems are examples. Nothing in this Recommendation should be construed as requiring that such applications use identity as their equality relationship when computing.
Any value incomparable with the value used for the four bounding facets (·minInclusive·, ·maxInclusive·, ·minExclusive·, and ·maxExclusive·) will be excluded from the resulting restricted ·value space·. In particular, when "NaN" is used as a facet value for a bounding facet, since no other float values are ·comparable· with it, the result is a ·value space· either having NaN as its only member (the inclusive cases) or that is empty (the exclusive cases). If any other value is used for a bounding facet, NaN will be excluded from the resulting restricted ·value space·; to add NaN back in requires union with the NaN-only space.
This datatype differs from that of [IEEE 754-1985] in that there is only one NaN and only one zero. This makes the equality and ordering of values in the data space differ from that of [IEEE 754-1985] only in that for schema purposes NaN = NaN.

A ·literal· in the ·lexical space· representing a decimal number d maps to the normalized value in the ·value space· of float that is closest to d in the sense defined by [Clinger, WD (1990)]; if d is exactly halfway between two such values then the even value is chosen.

3.3.5.1 Value Space

The ·value space· of float contains the non-zero numbers  m × 2e , where m is an integer whose absolute value is less than 224, and e is an integer between −149 and 104, inclusive.  In addition to these values, the ·value space· of float also contains the following ·special values·positiveZero, negativeZero, positiveInfinity, negativeInfinity, and notANumber.

Note: As explained below, the ·lexical representation· of the float value notANumber is 'NaN'.  Accordingly, in English text we generally use 'NaN' to refer to that value.  Similarly, we use 'INF' and '−INF' to refer to the two values positiveInfinity and negativeInfinity, and '0' and '−0' to refer to positiveZero and negativeZero.
Equality and order for float are defined as follows:
  • Equality is identity, except that  0 = −0  (although they are not identical) and  NaN ≠ NaN  (although NaN is of course identical to itself).
    0 and −0 are thus equivalent for purposes of enumerations and identity constraints, as well as for minimum and maximum values.
  • For the basic values, the order relation on float is the order relation for rational numbers.  INF is greater than all other non-NaN values; −INF is less than all other non-NaN values.  NaN is ·incomparable· with any value in the ·value space· including itself.  0 and −0 are greater than all the negative numbers and less than all the positive numbers.
Note: Any value ·incomparable· with the value used for the four bounding facets (·minInclusive·, ·maxInclusive·, ·minExclusive·, and ·maxExclusive·) will be excluded from the resulting restricted ·value space·.  In particular, when NaN is used as a facet value for a bounding facet, since no float values are ·comparable· with it, the result is a ·value space· that is empty.  If any other value is used for a bounding facet, NaN will be excluded from the resulting restricted ·value space·; to add NaN back in requires union with the NaN-only space (which may be derived using a pattern).
Note: The Schema 1.0 version of this datatype did not differentiate between 0 and −0 and NaN was equal to itself.  The changes were made to make the datatype more closely mirror [IEEE 754-1985].
Note: As specified elsewhere, enumerations test values for equality with one of the enumerated values. Because NaN ≠ NaN, including NaN in an enumeration does not have the effect of accepting NaNs as instances of the enumerated type; a union with a NaN-only datatype (which may be derived using the pattern "NaN") can be used instead.
3.3.5.2 Lexical representation

float values have a lexical representation consisting of a mantissa followed, optionally, by the character 'E' or 'e', followed by an exponent.  The exponent ·must· be an integer.  The mantissa must be a decimal number.  The representations for exponent and mantissa must follow the lexical rules for integer and decimal.  If the 'E' or 'e' and the following exponent are omitted, an exponent value of 0 is assumed.

The special values positive and negative infinity and not-a-number have lexical representations INF, -INF and NaN, respectively. Lexical representations for zero may take a positive or negative sign.

For example, -1E4, 1267.43233E12, 12.78e-2, 12 , -0, 0 and INF are all legal ·literals· for float.

3.3.5.3 Canonical representation

The ·canonical representation· for float is defined by prohibiting certain options from the Lexical representation (§3.3.5.2).  Specifically, the exponent must be indicated by "E".  Leading zeroes and the preceding optional "+" sign are prohibited in the exponent.  If the exponent is zero, it must be indicated by "E0". For the mantissa, the preceding optional "+" sign is prohibited and the decimal point is required. Leading and trailing zeroes are prohibited subject to the following: number representations must be normalized such that there is a single digit which is non-zero to the left of the decimal point and at least a single digit to the right of the decimal point unless the value being represented is zero. The ·canonical representation· for zero is 0.0E0.

3.3.5.4 Lexical Mapping
The ·lexical space· of float is the set of all decimal numerals with or without a decimal point, numerals in scientific (exponential) notation, and the ·literals· 'INF', '+INF', '-INF', and 'NaN' The floatRep production is equivalent to this regular expression (after whitespace is removed from the regular expression):

(\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)([Ee](\+|-)?[0-9]+)?
|(\+|-)?INF|NaN

The float datatype is designed to implement for schema processing the single-precision floating-point datatype of [IEEE 754-1985].  That specification does not specify specific ·lexical representations·, but does prescribe requirements on any ·lexical mapping· used.  Any ·lexical mapping· that maps the ·lexical space· just described onto the ·value space·, is a function, satisfies the requirements of [IEEE 754-1985], and correctly handles the mapping of the literals 'INF', 'NaN', etc., to the ·special values·, satisfies the conformance requirements of this specification.

Since IEEE allows some variation in rounding of values, processors conforming to this specification may exhibit some variation in their ·lexical mappings·.

The ·lexical mapping· ·floatLexicalMap· is provided as an example of a simple algorithm that yields a conformant mapping, and that provides the most accurate rounding possible—and is thus useful for insuring inter-implementation reproducibility and inter-implementation round-tripping.  The simple rounding algorithm used in ·floatLexicalMap· may be more efficiently implemented using the algorithms of [Clinger, WD (1990)].

Note: The Schema 1.0 version of this datatype did not permit rounding algorithms whose results differed from [Clinger, WD (1990)].

The ·canonical mapping· ·floatCanonicalMap· is provided as an example of a mapping that does not produce unnecessarily long ·canonical representations·.  Other algorithms which do not yield identical results for mapping from float values to character strings are permitted by [IEEE 754-1985].

3.3.5.5 Constraining facets Facets

float has the following ·constraining facets·:

float and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

Datatypes derived by restriction from float may also specify values for the following ·constraining facets·:

float has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = true
  • cardinality = finite
  • numeric = true

3.3.6 double

[Definition:]  The double datatype is patterned after patterned after the IEEE double-precision 64-bit floating point datatype [IEEE 754-1985].  The basic ·value space· of double consists of the values m × 2^e, where m is an integer whose absolute value is less than 253, and e is an integer between -1075 and 970, inclusive.  In addition to the basic ·value space· described above, the ·value space· of double also contains the following three special values: positive and negative infinity and not-a-number (NaN). The ·order-relation· on double is: x < y iff y - x is positive for x and y in the value space. Positive infinity is greater than all other non-NaN values. NaN equals itself but is incomparable with (neither greater than nor less than) any other value in the ·value space·.   Each floating point datatype has a value space that is a subset of the rational numbers.  Floating point numbers are often used to approximate arbitrary real numbers.

Note: The only significant differences between float and double are the three defining constants 53 (vs 24), −1074 (vs −149), and 971 (vs 104).
Note: "Equality" in this Recommendation is defined to be "identity" (i.e., values that are identical in the ·value space· are equal and vice versa). Identity must be used for the few operations that are defined in this Recommendation. Applications using any of the datatypes defined in this Recommendation may use different definitions of equality for computational purposes; [IEEE 754-1985]-based computation systems are examples. Nothing in this Recommendation should be construed as requiring that such applications use identity as their equality relationship when computing.
Any value incomparable with the value used for the four bounding facets (·minInclusive·, ·maxInclusive·, ·minExclusive·, and ·maxExclusive·) will be excluded from the resulting restricted ·value space·. In particular, when "NaN" is used as a facet value for a bounding facet, since no other double values are ·comparable· with it, the result is a ·value space· either having NaN as its only member (the inclusive cases) or that is empty (the exclusive cases). If any other value is used for a bounding facet, NaN will be excluded from the resulting restricted ·value space·; to add NaN back in requires union with the NaN-only space.
This datatype differs from that of [IEEE 754-1985] in that there is only one NaN and only one zero. This makes the equality and ordering of values in the data space differ from that of [IEEE 754-1985] only in that for schema purposes NaN = NaN.

A ·literal· in the ·lexical space· representing a decimal number d maps to the normalized value in the ·value space· of double that is closest to d; if d is exactly halfway between two such values then the even value is chosen. This is the best approximation of d ([Clinger, WD (1990)], [Gay, DM (1990)]), which is more accurate than the mapping required by [IEEE 754-1985].

3.3.6.1 Value Space

The ·value space· of double contains the non-zero numbers  m × 2e , where m is an integer whose absolute value is less than 253, and e is an integer between −1074 and 971, inclusive.  In addition to these values, the ·value space· of double also contains the following ·special values·positiveZero, negativeZero, positiveInfinity, negativeInfinity, and notANumber.

Note: As explained below, the ·lexical representation· of the double value notANumber is 'NaN'.  Accordingly, in English text we generally use 'NaN' to refer to that value.  Similarly, we use 'INF' and '−INF' to refer to the two values positiveInfinity and negativeInfinity, and '0' and '−0' to refer to positiveZero and negativeZero.
Equality and order for double are defined as follows:
  • Equality is identity, except that  0 = −0  (although they are not identical) and  NaN ≠ NaN  (although NaN is of course identical to itself).
    0 and −0 are thus equivalent for purposes of enumerations, identity constraints, and minimum and maximum values.
  • For the basic values, the order relation on double is the order relation for rational numbers.  INF is greater than all other non-NaN values; −INF is less than all other non-NaN values.  NaN is ·incomparable· with any value in the ·value space· including itself.  0 and −0 are greater than all the negative numbers and less than all the positive numbers.
Note: Any value ·incomparable· with the value used for the four bounding facets (·minInclusive·, ·maxInclusive·, ·minExclusive·, and ·maxExclusive·) will be excluded from the resulting restricted ·value space·.  In particular, when NaN is used as a facet value for a bounding facet, since no double values are ·comparable· with it, the result is a ·value space· that is empty.  If any other value is used for a bounding facet, NaN will be excluded from the resulting restricted ·value space·; to add NaN back in requires union with the NaN-only space (which may be derived with a pattern).
Note: The Schema 1.0 version of this datatype did not differentiate between 0 and −0 and NaN was equal to itself.  The changes were made to make the datatype more closely mirror [IEEE 754-1985].
Note: As specified elsewhere, enumerations test values for equality with one of the enumerated values. Because NaN ≠ NaN, including NaN in an enumeration does not have the effect of accepting NaNs as instances of the enumerated type; a union with a NaN-only datatype (which may be derived using the pattern "NaN") can be used instead.
3.3.6.2 Lexical representation

double values have a lexical representation consisting of a mantissa followed, optionally, by the character "E" or "e", followed by an exponent.  The exponent ·must· be an integer.  The mantissa must be a decimal number.  The representations for exponent and mantissa must follow the lexical rules for integer and decimal.  If the 'E' or 'e' and the following exponent are omitted, an exponent value of 0 is assumed.

The special values positive and negative infinity and not-a-number have lexical representations INF, -INF and NaN, respectively. Lexical representations for zero may take a positive or negative sign.

For example, -1E4, 1267.43233E12, 12.78e-2, 12 , -0, 0 and INF are all legal ·literals· for double.

3.3.6.3 Canonical representation

The ·canonical representation· for double is defined by prohibiting certain options from the Lexical representation (§3.3.6.2).  Specifically, the exponent must be indicated by "E".  Leading zeroes and the preceding optional "+" sign are prohibited in the exponent. If the exponent is zero, it must be indicated by "E0". For the mantissa, the preceding optional "+" sign is prohibited and the decimal point is required. Leading and trailing zeroes are prohibited subject to the following: number representations must be normalized such that there is a single digit which is non-zero to the left of the decimal point and at least a single digit to the right of the decimal point unless the value being represented is zero. The ·canonical representation· for zero is 0.0E0.

3.3.6.4 Lexical Mapping
The ·lexical space· of double is the set of all decimal numerals with or without a decimal point, numerals in scientific (exponential) notation, and the ·literals· 'INF', '+INF', '-INF', and 'NaN' The doubleRep production is equivalent to this regular expression (after whitespace is eliminated from the expression):

(\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)([Ee](\+|-)?[0-9]+)? |(\+|-)?INF|NaN

The double datatype is designed to implement for schema processing the double-precision floating-point datatype of [IEEE 754-1985].  That specification does not specify specific ·lexical representations·, but does prescribe requirements on any ·lexical mapping· used.  Any ·lexical mapping· that maps the ·lexical space· just described onto the ·value space·, is a function, satisfies the requirements of [IEEE 754-1985], and correctly handles the mapping of the literals 'INF', 'NaN', etc., to the ·special values·, satisfies the conformance requirements of this specification.

Since IEEE allows some variation in rounding of values, processors conforming to this specification may exhibit some variation in their ·lexical mappings·.

The ·lexical mapping· ·doubleLexicalMap· is provided as an example of a simple algorithm that yields a conformant mapping, and that provides the most accurate rounding possible—and is thus useful for insuring inter-implementation reproducibility and inter-implementation round-tripping.  The simple rounding algorithm used in ·doubleLexicalMap· may be more efficiently implemented using the algorithms of [Clinger, WD (1990)].

Note: The Schema 1.0 version of this datatype did not permit rounding algorithms whose results differed from [Clinger, WD (1990)].

The ·canonical mapping· ·doubleCanonicalMap· is provided as an example of a mapping that does not produce unnecessarily long ·canonical representations·.  Other algorithms which do not yield identical results for mapping from float values to character strings are permitted by [IEEE 754-1985].

3.3.6.5 Constraining facets Facets

double has the following ·constraining facets·:

double and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

Datatypes derived by restriction from double may also specify values for the following ·constraining facets·:

double has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = true
  • cardinality = finite
  • numeric = true

3.3.7 duration

[Definition:]   duration represents a duration of time. The ·value space· of duration is a six-dimensional space where the coordinates designate the Gregorian year, month, day, hour, minute, and second components defined in § 5.5.3.2 of [ISO 8601], respectively. These components are ordered in their significance by their order of appearance i.e. as year, month, day, hour, minute, and second.

Note: All ·minimally conforming· processors ·must· support year values with a minimum of 4 digits (i.e., YYYY) and a minimum fractional second precision of milliseconds or three decimal digits (i.e. s.sss). However, ·minimally conforming· processors ·may· set an application-defined limit on the maximum number of digits they are prepared to support in these two cases, in which case that application-defined maximum number ·must· be clearly documented.

[Definition:]  duration is a datatype that represents durations of time.  The concept of duration being captured is drawn from those of [ISO 8601], specifically durations without fixed endpoints.  For example, "15 days" (whose most common lexical representation in duration is "'P15D'") is a duration value; "15 days beginning 12 July 1995" and "15 days ending 12 July 1995" are not duration values.  duration can provide addition and subtraction operations between duration values and between duration/dateTime value pairs, and can be the result of subtracting dateTime values.  However, only addition to dateTime is required for XML Schema processing and is defined in the function ·dateTimePlusDuration·.

3.3.7.1 Value Space
Duration values can be modelled as two-property tuples. Each value consists of an integer number of months and a decimal number of seconds. The ·seconds· value must not be negative if the ·months· value is positive and must not be positive if the ·months· is negative.
Properties of duration Values
a decimal value; must not be negative if ·months· is positive, and must not be positive if ·months· is negative.
duration is partially ordered.  Equality of duration is defined in terms of equality of dateTime; order for duration is defined in terms of the order of dateTime. Specifically, the equality or order of two duration values is determined by adding each duration in the pair to each of the following four dateTime values:
  • 1696-09-01T00:00:00Z
  • 1697-02-01T00:00:00Z
  • 1903-03-01T00:00:00Z
  • 1903-07-01T00:00:00Z
If all four resulting dateTime value pairs are ordered the same way (less than, equal, or greater than), then the original pair of duration values is ordered the same way; otherwise the original pair is ·incomparable·.
Note: These four values are chosen so as to maximize the possible differences in results that could occur, such as the difference when adding P1M and P30D:  1697-02-01T00:00:00Z + P1M < 1697-02-01T00:00:00Z + P30D , but 1903-03-01T00:00:00Z + P1M > 1903-03-01T00:00:00Z + P30D , so that  P1M <> P30D .  If two duration values are ordered the same way when added to each of these four dateTime values, they will retain the same order when added to any other dateTime values.  Therefore, two duration values are incomparable if and only if they can ever result in different orders when added to any dateTime value.

Under the definition just given, two duration values are equal if and only if they are identical.

Note: There are many ways to implement duration, some of which do not base the implementation on the two-component model.  This specification does not prescribe any particular implementation, as long as the visible results are isomorphic to those described herein.
Note: See the conformance notes in Partial Implementation of Infinite Datatypes (§5.4), which apply to this datatype.
3.3.7.2 Lexical representation

The lexical representation for duration is the [ISO 8601] extended format PnYn MnDTnH nMnS, where nY represents the number of years, nM the number of months, nD the number of days, 'T' is the date/time separator, nH the number of hours, nM the number of minutes and nS the number of seconds. The number of seconds can include decimal digits to arbitrary precision.

The values of the Year, Month, Day, Hour and Minutes components are not restricted but allow an arbitrary integer. Similarly, the value of the Seconds component allows an arbitrary decimal. Thus, the lexical representation of duration does not follow the alternative format of § 5.5.3.2.1 of [ISO 8601].

An optional preceding minus sign ('-') is allowed, to indicate a negative duration. If the sign is omitted a positive duration is indicated. See also ISO 8601 Date and Time Formats (§G).

For example, to indicate a duration of 1 year, 2 months, 3 days, 10 hours, and 30 minutes, one would write: P1Y2M3DT10H30M. One could also indicate a duration of minus 120 days as: -P120D.

Reduced precision and truncated representations of this format are allowed provided they conform to the following:

  • If the number of years, months, days, hours, minutes, or seconds in any expression equals zero, the number and its corresponding designator ·may· be omitted. However, at least one number and its designator ·must· be present.
  • The seconds part ·may· have a decimal fraction.
  • The designator 'T' shall be absent if all of the time items are absent. The designator 'P' must always be present.

For example, P1347Y, P1347M and P1Y2MT2H are all allowed; P0Y1347M and P0Y1347M0D are allowed. P-1347M is not allowed although -P1347M is allowed. P1Y2MT is not allowed.

3.3.7.3 Lexical Mapping
The ·lexical representations· of duration are more or less based on the pattern:

PnYnMnDTnHnMnS

More precisely, the ·lexical space· of duration is the set of character strings that satisfy durationLexicalRep as defined by the following productions:
Lexical Representation Fragments
duYearFrag ::= unsignedNoDecimalPtNumeral 'Y'
duMonthFrag ::= unsignedNoDecimalPtNumeral 'M'
duDayFrag ::= unsignedNoDecimalPtNumeral 'D'
duHourFrag ::= unsignedNoDecimalPtNumeral 'H'
duMinuteFrag ::= unsignedNoDecimalPtNumeral 'M'
duYearMonthFrag ::= (duYearFrag duMonthFrag?) | duMonthFrag
duDayTimeFrag ::= (duDayFrag duTimeFrag?) | duTimeFrag
Lexical Representation
durationLexicalRep ::= '-'? 'P' ((duYearMonthFrag duDayTimeFrag?) | duDayTimeFrag)

Thus, a durationLexicalRep consists of one or more of a duYearFrag, duMonthFrag, duDayFrag, duHourFrag, duMinuteFrag, and/or duSecondFrag, in order, with letters 'P' and 'T' (and perhaps a '-') where appropriate.

The language accepted by the durationLexicalRep production is the set of strings which satisfy all of the following three regular expressions:
  • The expression

    -?P([0-9]+Y)?([0-9]+M)?([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+(\.[0-9]+)?S)?)?

    matches only strings in which the fields occur in the proper order.
  • The expression '.*[YMDHS].*' matches only strings in which at least one field occurs.
  • The expression '.*[^T]' matches only strings in which 'T' is not the final character, so that if 'T' appears, something follows it. The first rule ensures that what follows 'T' will be an hour, minute, or second field.
The intersection of these three regular expressions is equivalent to the following (after removal of the white space inserted here for legibility):
-?P(([0-9]+Y)([0-9]+M)?([0-9]+D)?(T(([0-9]+H)([0-9]+M)?([0-9]+(\.[0-9]+)?S)?|([0-9]+M)?([0-9]+(\.[0-9]+)?S)?|([0-9]+(\.[0-9]+)?S)))?
   |([0-9]+M)([0-9]+D)?(T(([0-9]+H)([0-9]+M)?([0-9]+(\.[0-9]+)?S)?|([0-9]+M)?([0-9]+(\.[0-9]+)?S)?|([0-9]+(\.[0-9]+)?S)))?
   |([0-9]+D)?(T(([0-9]+H)([0-9]+M)?([0-9]+(\.[0-9]+)?S)?|([0-9]+M)?([0-9]+(\.[0-9]+)?S)?|([0-9]+(\.[0-9]+)?S)))?
   |T(([0-9]+H)([0-9]+M)?([0-9]+(\.[0-9]+)?S)?
     |([0-9]+M)?([0-9]+(\.[0-9]+)?S)?
     |([0-9]+(\.[0-9]+)?S)))

The ·lexical mapping· for duration is ·durationMap·.

·The canonical mapping· for duration is ·durationCanonicalMap·.

3.3.7.4 Order relation on duration
In general, the ·order-relation· on duration is a partial order since there is no determinate relationship between certain durations such as one month (P1M) and 30 days (P30D). The ·order-relation· of two duration values x and y is x < y iff s+x < s+y for each qualified dateTime s in the list below. These values for s cause the greatest deviations in the addition of dateTimes and durations. Addition of durations to time instants is defined in Adding durations to dateTimes (§H).
  • 1696-09-01T00:00:00Z
  • 1697-02-01T00:00:00Z
  • 1903-03-01T00:00:00Z
  • 1903-07-01T00:00:00Z

The following table shows the strongest relationship that can be determined between example durations. The symbol <> means that the order relation is indeterminate. Note that because of leap-seconds, a seconds field can vary from 59 to 60. However, because of the way that addition is defined in Adding durations to dateTimes (§H), they are still totally ordered.

 Relation
P1Y> P364D<> P365D <> P366D< P367D
P1M> P27D<> P28D<> P29D<> P30D<> P31D< P32D
P5M> P149D<> P150D<> P151D<> P152D<> P153D< P154D

Implementations are free to optimize the computation of the ordering relationship. For example, the following table can be used to compare durations of a small number of months against days.

 Months12345678910111213...
DaysMinimum285989120150181212242273303334365393...
Maximum316292123153184215245276306337366397...
3.3.7.5 Facet Comparison for durations

In comparing duration values with minInclusive, minExclusive, maxInclusive and maxExclusive facet values, indeterminate comparisons should be considered as "false".

3.3.7.6 Totally ordered durations

Certain derived datatypes of durations can be guaranteed have a total order. For this, they must have fields from only one row in the list below and the time zone must either be required or prohibited.

  • year, month
  • day, hour, minute, second

For example, a datatype could be defined to correspond to the [SQL] datatype Year-Month interval that required a four digit year field and a two digit month field but required all other fields to be unspecified. This datatype could be defined as below and would have a total order.

<simpleType name='SQL-Year-Month-Interval'>
    <restriction base='duration'>
      <pattern value='P\p{Nd}{4}Y\p{Nd}{2}M'/>
    </restriction>
</simpleType>
3.3.7.7 constraining facets Facets

duration has the following ·constraining facets·:

duration and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

Datatypes derived by restriction from duration may also specify values for the following ·constraining facets·:

duration has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = false
  • cardinality = countably infinite
  • numeric = false
3.3.7.8 Related Datatypes

The following ·built-in· datatypes are ·derived· from duration

3.3.8 dateTime

[Definition:]   dateTime values may be viewed as objects with integer-valued year, month, day, hour and minute properties, a decimal-valued second property, and a boolean timezoned property. Each such object also has one decimal-valued method or computed property, timeOnTimeline, whose value is always a decimal number; the values are dimensioned in seconds, the integer 0 is 0001-01-01T00:00:00 and the value of timeOnTimeline for other dateTime values is computed using the Gregorian algorithm as modified for leap-seconds. The timeOnTimeline values form two related "timelines", one for timezoned values and one for non-timezoned values. Each timeline is a copy of the ·value space· of decimal, with integers given units of seconds.

dateTime represents instants of time, optionally marked with a particular time zone offset.  Values representing the same instant but having different time zone offsets are equal but not identical.

The ·value space· of dateTime is closely related to the dates and times described in ISO 8601. For clarity, the text above specifies a particular origin point for the timeline. It should be noted, however, that schema processors need not expose the timeOnTimeline value to schema users, and there is no requirement that a timeline-based implementation use the particular origin described here in its internal representation. Other interpretations of the ·value space· which lead to the same results (i.e., are isomorphic) are of course acceptable.

All timezoned times are Coordinated Universal Time (·UTC·, sometimes called "Greenwich Mean Time"). Other timezones indicated in lexical representations are converted to ·UTC· during conversion of literals to values. "Local" or untimezoned times are presumed to be the time in the timezone of some unspecified locality as prescribed by the appropriate legal authority; currently there are no legally prescribed timezones which are durations whose magnitude is greater than 14 hours. The value of each numeric-valued property (other than timeOnTimeline) is limited to the maximum value within the interval determined by the next-higher property. For example, the day value can never be 32, and cannot even be 29 for month 02 and year 2002 (February 2002).

Note: The date and time datatypes described in this recommendation were inspired by [ISO 8601].  '0001' is the lexical representation of the year 1 of the Common Era (1 CE, sometimes written "AD 1" or "1 AD").  There is no year 0, and '0000' is not a valid lexical representation. '-0001' is the lexical representation of the year 1 Before Common Era (1 BCE, sometimes written "1 BC").
Those using this (1.0) version of this Recommendation to represent negative years should be aware that the interpretation of lexical representations beginning with a '-' is likely to change in subsequent versions.
[ISO 8601] makes no mention of the year 0; in [ISO 8601:1998 Draft Revision] the form '0000' was disallowed and this recommendation disallows it as well. However, [ISO 8601:2000 Second Edition], which became available just as we were completing version 1.0, allows the form '0000', representing the year 1 BCE.  A number of external commentators have also suggested that '0000' be allowed, as the lexical representation for 1 BCE, which is the normal usage in astronomical contexts.  It is the intention of the XML Schema Working Group to allow '0000' as a lexical representation in the dateTime, date, gYear, and gYearMonth datatypes in a subsequent version of this Recommendation. '0000' will be the lexical representation of 1 BCE (which is a leap year), '-0001' will become the lexical representation of 2 BCE (not 1 BCE as in this (1.0) version), '-0002' of 3 BCE, etc.
Note: See the conformance note in (§) which applies to this datatype as well.
3.3.8.1 Value Space

dateTime uses the date/timeSevenPropertyModel, with no properties except ·timezoneOffset· permitted to be absent. The ·timezoneOffset· property remains ·optional·.

Note: In version 1.0 of this specification, the ·year· property was not permitted to have the value zero. The year before the year 1 in the proleptic Gregorian calendar, traditionally referred to as 1 BC or as 1 BCE, was represented by a ·year· value of −1, 2 BCE by −2, and so forth. Of course, many, perhaps most, references to 1 BCE (or 1 BC) actually refer not to a year in the proleptic Gregorian calendar but to a year in the Julian or "old style" calendar; the two correspond approximately but not exactly to each other.
In this version of this specification, two changes are made in order to agree with existing usage. First, ·year· is permitted to have the value zero. Second, the interpretation of ·year· values is changed accordingly: a ·year· value of zero represents 1 BCE, −1 represents 2 BCE, etc. This representation simplifies interval arithmetic and leap-year calculation for dates before the common era (which may be why astronomers and others interested in such calculations with the proleptic Gregorian calendar have adopted it), and is consistent with the current edition of [ISO 8601].
Note that 1 BCE, 5 BCE, and so on (years 0000, -0004, etc. in the lexical representation defined here) are leap years in the proleptic Gregorian calendar used for the date/time datatypes defined here. Version 1.0 of this specification was unclear about the treatment of leap years before the common era. If existing schemas or data specify dates of 29 February for any years before the common era, then some values giving a date of 29 February which were valid under a plausible interpretation of XSD 1.0 will be invalid under this specification, and some which were invalid will be valid. With that possible exception, schemas and data valid under the old interpretation remain valid under the new.
Constraint: Day-of-month Values
The ·day· value must be no more than 30 if ·month· is one of 4, 6, 9, or 11; no more than 28 if ·month· is 2 and ·year· is not divisible 4, or is divisible by 100 but not by 400; and no more than 29 if ·month· is 2 and ·year· is divisible by 400, or by 4 but not by 100.
Note: See the conformance note in Partial Implementation of Infinite Datatypes (§5.4) which applies to the ·year· and ·second· values of this datatype.

Equality and order are as prescribed in The Seven-property Model (§D.2.1)dateTime values are ordered by their ·timeOnTimeline· value.

Note: Since the order of a dateTime value having a ·timezoneOffset· relative to another value whose ·timezoneOffset· is absent is determined by imputing time zone offsets of both +14:00 and −14:00 to the value with no time zone offset, many such combinations will be ·incomparable· because the two imputed time zone offsets yield different orders.
Although dateTime and other types related to dates and times have only a partial order, it is possible for datatypes derived from dateTime to have total orders, if they are restricted (e.g. using the pattern facet) to the subset of values with, or the subset of values without, time zone offsets. Similar restrictions on other date- and time-related types will similarly produce totally ordered subtypes. Note, however, that such restrictions do not affect the value shown, for a given Simple Type Definition, in the ordered facet.
Note: Order and equality are essentially the same for dateTime in this version of this specification as they were in version 1.0.  However, since values now distinguish time zone offsets, equal values with different ·timezoneOffset·s are not identical, and values with extreme ·timezoneOffset·s may no longer be equal to any value with a smaller ·timezoneOffset·.
3.3.8.2 Lexical representation

The ·lexical space· of dateTime consists of finite-length sequences of characters of the form: '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?, where

  • '-'? yyyy is a four-or-more digit optionally negative-signed numeral that represents the year; if more than four digits, leading zeroes are prohibited, and '0000' is prohibited (see the Note above (§3.3.8); also note that a plus sign is not permitted);
  • the remaining '-'s are separators between parts of the date portion;
  • the first mm is a two-digit numeral that represents the month;
  • dd is a two-digit numeral that represents the day;
  • 'T' is a separator indicating that time-of-day follows;
  • hh is a two-digit numeral that represents the hour; '24' is permitted if the minutes and seconds represented are zero, and the dateTime value so represented is the first instant of the following day (the hour property of a dateTime object in the ·value space· cannot have a value greater than 23);
  • ':' is a separator between parts of the time-of-day portion;
  • the second mm is a two-digit numeral that represents the minute;
  • ss is a two-integer-digit numeral that represents the whole seconds;
  • '.' s+ (if present) represents the fractional seconds;
  • zzzzzz (if present) represents the timezone (as described below).

For example, 2002-10-10T12:00:00-05:00 (noon on 10 October 2002, Central Daylight Savings Time as well as Eastern Standard Time in the U.S.) is 2002-10-10T17:00:00Z, five hours later than 2002-10-10T12:00:00Z.

For further guidance on arithmetic with dateTimes and durations, see Adding durations to dateTimes (§H).

3.3.8.3 Canonical representation
Except for trailing fractional zero digits in the seconds representation, '24:00:00' time representations, and timezone (for timezoned values), the mapping from literals to values is one-to-one. Where there is more than one possible representation, the ·canonical representation· is as follows:
  • The 2-digit numeral representing the hour must not be '24';
  • The fractional second string, if present, must not end in '0';
  • for timezoned values, the timezone must be represented with 'Z' (All timezoned dateTime values are ·UTC·.).
3.3.8.4 Lexical Mapping
The lexical representations for dateTime are as follows:
Lexical Space
dateTimeLexicalRep ::= yearFrag '-monthFrag '-dayFrag 'T' ((hourFrag ':minuteFrag ':secondFrag) | endOfDayFrag) timezoneFrag?   Constraint:  Day-of-month Representations
Constraint: Day-of-month Representations
Within a dateTimeLexicalRep, a dayFrag must not begin with the digit '3' or be '29' unless the value to which it would map would satisfy the value constraint on ·day· values ("Constraint: Day-of-month Values") given above.
In such representations:
  • yearFrag is a numeral consisting of at least four decimal digits, optionally preceded by a minus sign; leading '0' digits are prohibited except to bring the digit count up to four.  It represents the ·year· value.
  • Subsequent '-', 'T', and ':', separate the various numerals.
  • monthFrag, dayFrag, hourFrag, and minuteFrag are numerals consisting of exactly two decimal digits.  They represent the ·month·, ·day·, ·hour·, and ·minute· values respectively.
  • secondFrag is a numeral consisting of exactly two decimal digits, or two decimal digits, a decimal point, and one or more trailing digits.  It represents the ·second· value.
  • Alternatively, endOfDayFrag combines the hourFrag, minuteFrag, minuteFrag, and their separators to represent midnight of the day, which is the first moment of the next day.
  • timezoneFrag, if present, specifies an offset between UTC and local time. Time zone offsets are a count of minutes (expressed in timezoneFrag as a count of hours and minutes) that are added or subtracted from UTC time to get the "local" time.  'Z' is an alternative representation of the time zone offset '00:00', which is, of course, zero minutes from UTC.
    For example, 2002-10-10T12:00:00−05:00 (noon on 10 October 2002, Central Daylight Savings Time as well as Eastern Standard Time in the U.S.) is equal to 2002-10-10T17:00:00Z, five hours later than 2002-10-10T12:00:00Z.
    Note: For the most part, this specification adopts the distinction between 'timezone' and 'timezone offset' laid out in [Timezones]. Version 1.0 of this specification did not make this distinction, but used the term 'timezone' for the time zone offset information associated with date- and time-related datatypes. Some traces of the earlier usage remain visible in this and other specifications. The names timezoneFrag and explicitTimezone are such traces ; others will be found in the names of functions defined in [XQuery 1.0 and XPath 2.0 Functions and Operators], or in references in this specification to "timezoned" and "untimezoned" values.
The dateTimeLexicalRep production is equivalent to this regular expression once whitespace is removed.
-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?
-?([1-9][0-9]{3,}|0[0-9]{3})
-(0[1-9]|1[0-2])
-(0[1-9]|[12][0-9]|3[01])
T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))
(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?
Note that neither the dateTimeLexicalRep production nor this regular expression alone enforce the constraint on dateTimeLexicalRep given above.

The ·lexical mapping· for dateTime is ·dateTimeLexicalMap·. The ·canonical mapping· is ·dateTimeCanonicalMap·.

3.3.8.5 Timezones

Timezones are durations with (integer-valued) hour and minute properties (with the hour magnitude limited to at most 14, and the minute magnitude limited to at most 59, except that if the hour magnitude is 14, the minute value must be 0); they may be both positive or both negative.

The lexical representation of a timezone is a string of the form: (('+' | '-') hh ':' mm) | 'Z', where

  • hh is a two-digit numeral (with leading zeroes as required) that represents the hours,
  • mm is a two-digit numeral that represents the minutes,
  • '+' indicates a nonnegative duration,
  • '-' indicates a nonpositive duration.

The mapping so defined is one-to-one, except that '+00:00', '-00:00', and 'Z' all represent the same zero-length duration timezone, ·UTC·; 'Z' is its ·canonical representation·.

When a timezone is added to a ·UTC· dateTime, the result is the date and time "in that timezone".  For example, 2002-10-10T12:00:00+05:00 is 2002-10-10T07:00:00Z and 2002-10-10T00:00:00+05:00 is 2002-10-09T19:00:00Z.

3.3.8.6 Order relation on dateTime

dateTime value objects on either timeline are totally ordered by their timeOnTimeline values; between the two timelines, dateTime value objects are ordered by their timeOnTimeline values when their timeOnTimeline values differ by more than fourteen hours, with those whose difference is a duration of 14 hours or less being incomparable.

In general, the ·order-relation· on dateTime is a partial order since there is no determinate relationship between certain instants. For example, there is no determinate ordering between (a) 2000-01-20T12:00:00 and (b) 2000-01-20T12:00:00Z. Based on timezones currently in use, (c) could vary from 2000-01-20T12:00:00+12:00 to 2000-01-20T12:00:00-13:00. It is, however, possible for this range to expand or contract in the future, based on local laws. Because of this, the following definition uses a somewhat broader range of indeterminate values: +14:00..-14:00.

The following definition uses the notation S[year] to represent the year field of S, S[month] to represent the month field, and so on. The notation (Q & "-14:00") means adding the timezone -14:00 to Q, where Q did not already have a timezone. This is a logical explanation of the process. Actual implementations are free to optimize as long as they produce the same results.

The ordering between two dateTimes P and Q is defined by the following algorithm:

A.Normalize P and Q. That is, if there is a timezone present, but it is not Z, convert it to Z using the addition operation defined in Adding durations to dateTimes (§H)

  • Thus 2000-03-04T23:00:00+03:00 normalizes to 2000-03-04T20:00:00Z

B. If P and Q either both have a time zone or both do not have a time zone, compare P and Q field by field from the year field down to the second field, and return a result as soon as it can be determined. That is:

  1. For each i in {year, month, day, hour, minute, second}
    1. If P[i] and Q[i] are both not specified, continue to the next i
    2. If P[i] is not specified and Q[i] is, or vice versa, stop and return P <> Q
    3. If P[i] < Q[i], stop and return P < Q
    4. If P[i] > Q[i], stop and return P > Q
  2. Stop and return P = Q

C.Otherwise, if P contains a time zone and Q does not, compare as follows:

  1. P < Q if P < (Q with time zone +14:00)
  2. P > Q if P > (Q with time zone -14:00)
  3. P <> Q otherwise, that is, if (Q with time zone +14:00) < P < (Q with time zone -14:00)

D. Otherwise, if P does not contain a time zone and Q does, compare as follows:

  1. P < Q if (P with time zone -14:00) < Q.
  2. P > Q if (P with time zone +14:00) > Q.
  3. P <> Q otherwise, that is, if (P with time zone +14:00) < Q < (P with time zone -14:00)

Examples:

DeterminateIndeterminate
2000-01-15T00:00:00 < 2000-02-15T00:00:002000-01-01T12:00:00 <> 1999-12-31T23:00:00Z
2000-01-15T12:00:00 < 2000-01-16T12:00:00Z2000-01-16T12:00:00 <> 2000-01-16T12:00:00Z
 2000-01-16T00:00:00 <> 2000-01-16T12:00:00Z
3.3.8.7 Totally ordered dateTimes

Certain derived types from dateTime can be guaranteed have a total order. To do so, they must require that a specific set of fields are always specified, and that remaining fields (if any) are always unspecified. For example, the date datatype without time zone is defined to contain exactly year, month, and day. Thus dates without time zone have a total order among themselves.

3.3.8.8 Constraining facets Facets

dateTime has the following ·constraining facets·:

dateTime and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

dateTime has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from dateTime may also specify values for the following ·constraining facets·:

dateTime has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = false
  • cardinality = countably infinite
  • numeric = false
3.3.8.9 Related Datatypes

The following ·built-in· datatype is ·derived· from dateTime

3.3.9 time

[Definition:]  time represents an instant of time that recurs every day.  The ·value space· of time is the space of time of day values as defined in § 5.3 of [ISO 8601].  Specifically, it is a set of zero-duration daily time instances.

time represents instants of time that recur at the same point in each calendar day, or that occur in some arbitrary calendar day.

Since the lexical representation allows an optional time zone indicator, time values are partially ordered because it may not be able to determine the order of two values one of which has a time zone and the other does not.  The order relation on time values is the Order relation on dateTime (§3.3.8.6) using an arbitrary date. See also Adding durations to dateTimes (§H).  Pairs of time values with or without time zone indicators are totally ordered.

Note: See the conformance note in (§) which applies to the seconds part of this datatype as well.
3.3.9.1 Value Space

time uses the date/timeSevenPropertyModel, with ·year·, ·month·, and ·day· required to be absent·timezoneOffset· remains ·optional·.

Note: See the conformance note in Partial Implementation of Infinite Datatypes (§5.4) which applies to the ·second· value of this datatype.

Equality and order are as prescribed in The Seven-property Model (§D.2.1)time values (points in time in an "arbitrary" day) are ordered taking into account their ·timezoneOffset·.

A calendar (or "local time") day with a larger positive time zone offset begins earlier than the same calendar day with a smaller (or negative) time zone offset. Since the time zone offsets allowed spread over 28 hours, it is possible for the period denoted by a given calendar day with one time zone offset to be completely disjoint from the period denoted by the same calendar day with a different offset — the earlier day ends before the later one starts.  The moments in time represented by a single calendar day are spread over a 52-hour interval, from the beginning of the day in the +14:00 time zone offset to the end of that day in the −14:00 time zone offset.

Note: The relative order of two time values, one of which has a ·timezoneOffset· of absent is determined by imputing time zone offsets of both +14:00 and −14:00 to the value without an offset. Many such combinations will be ·incomparable· because the two imputed time zone offsets yield different orders.  However, for a given untimezoned value, there will always be timezoned values at one or both ends of the 52-hour interval that are ·comparable· (because the interval of ·incomparability· is only 24 hours wide).
Date values with different time zone offsets that were identical in the 1.0 version of this specification, such as 2000-12-12+13:00 and 2000-12-11−11:00, are in this version of this specification equal (because they begin at the same moment on the time line) but are not identical (because they have and retain different time zone offsets).
3.3.9.2 Lexical representation

The lexical representation for time is the left truncated lexical representation for dateTime: hh:mm:ss.sss with optional following time zone indicator.  For example, to indicate 1:20 pm for Eastern Standard Time which is 5 hours behind Coordinated Universal Time (·UTC·), one would write: 13:20:00-05:00. See also ISO 8601 Date and Time Formats (§G).

3.3.9.3 Canonical representation

The ·canonical representation· for time is defined by prohibiting certain options from the Lexical representation (§3.3.9.2).  Specifically, either the time zone must be omitted or, if present, the time zone must be Coordinated Universal Time (·UTC·) indicated by a "Z". Additionally, the ·canonical representation· for midnight is 00:00:00.

3.3.9.4 Lexical Mappings
The lexical representations for time are "projections" of those of dateTime, as follows:
Lexical Space
timeLexicalRep ::= ((hourFrag ':minuteFrag ':secondFrag) | endOfDayFrag) timezoneFrag?
The timeLexicalRep production is equivalent to this regular expression, once whitespace is removed:

(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?

Note that neither the timeLexicalRep production nor this regular expression alone enforce the constraint on timeLexicalRep given above.

The ·lexical mapping· for time is ·timeLexicalMap·; the ·canonical mapping· is ·timeCanonicalMap·.

Note: The ·lexical mapping· maps '00:00:00' and '24:00:00' to the same value, namely midnight (·hour· = 0 , ·minute· = 0 , ·second· = 0).
3.3.9.5 Constraining facets Facets

time has the following ·constraining facets·:

time and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

time has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from time may also specify values for the following ·constraining facets·:

time has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.3.10 date

[Definition:]   The ·value space· of date consists of top-open intervals of exactly one day in length on the timelines of dateTime, beginning on the beginning moment of each day (in each timezone), i.e. '00:00:00', up to but not including '24:00:00' (which is identical with '00:00:00'date represents top-open intervals of exactly one day in length on the timelines of dateTime, beginning on the beginning moment of each day, up to but not including the beginning moment of the next day).  For nontimezoned values, the top-open intervals disjointly cover the nontimezoned timeline, one per day.  For timezoned values, the intervals begin at every minute and therefore overlap.

A "date object" is an object with year, month, and day properties just like those of dateTime objects, plus an optional timezone-valued timezone property. (As with values of dateTime timezones are a special case of durations.) Just as a dateTime object corresponds to a point on one of the timelines, a date object corresponds to an interval on one of the two timelines as just described.

timezoned date values track the starting moment of their day, as determined by their timezone; said timezone is generally recoverable for ·canonical representations·. [Definition:]   The recoverable timezone is that duration which is the result of subtracting the first moment (or any moment) of the timezoned date from the first moment (or the corresponding moment) ·UTC· on the same date. ·recoverable timezone·s are always durations between '+12:00' and '-11:59'.  This "timezone normalization" (which follows automatically from the definition of the date ·value space·) is explained more in Lexical representation (§3.3.10.2).

For example: the first moment of 2002-10-10+13:00 is 2002-10-10T00:00:00+13, which is 2002-10-09T11:00:00Z, which is also the first moment of 2002-10-09-11:00. Therefore 2002-10-10+13:00 is 2002-10-09-11:00; they are the same interval.

Note: For most timezones, either the first moment or last moment of the day (a dateTime value, always ·UTC·) will have a date portion different from that of the date itself! However, noon of that date (the midpoint of the interval) in that (normalized) timezone will always have the same date portion as the date itself, even when that noon point in time is normalized to ·UTC·.  For example, 2002-10-10-05:00 begins during 2002-10-09Z and 2002-10-10+05:00 ends during 2002-10-11Z, but noon of both 2002-10-10-05:00 and 2002-10-10+05:00 falls in the interval which is 2002-10-10Z.
Note: See the conformance note in (§) which applies to the year part of this datatype as well.
3.3.10.1 Value Space

date uses the date/timeSevenPropertyModel, with ·hour·, ·minute·, and ·second· required to be absent·timezoneOffset· remains ·optional·.

Constraint: Day-of-month Values
The ·day· value must be no more than 30 if ·month· is one of 4, 6, 9, or 11, no more than 28 if ·month· is 2 and ·year· is not divisble 4, or is divisible by 100 but not by 400, and no more than 29 if ·month· is 2 and ·year· is divisible by 400, or by 4 but not by 100.
Note: See the conformance note in Partial Implementation of Infinite Datatypes (§5.4) which applies to the ·year· value of this datatype.

Equality and order are as prescribed in The Seven-property Model (§D.2.1).

Note: In version 1.0 of this specification, date values did not retain a time zone offset explicitly, but for offsets not too far from zero their time zone offset could be recovered based on their value's first moment on the timeline.  The date/timeSevenPropertyModel retains all time zone offsets.
Examples that show the difference from version 1.0 (see Lexical Mapping (§3.3.10.4) for the notations):
  • A day is a calendar (or "local time") day offset from ·UTC· by the appropriate interval; this is now true for all ·day· values, including those with time zone offsets outside the range +12:00 through -11:59 inclusive:
    2000-12-12+13:00 < 2000-12-12+11:00  (just as 2000-12-12+12:00 has always been less than 2000-12-12+11:00, but in version 1.0  2000-12-12+13:00 > 2000-12-12+11:00 , since 2000-12-12+13:00's "recoverable time zone offset" was −11:00)
  • Similarly:
    2000-12-12+13:00 = 2000-12-13−11:00  (whereas under 1.0, as just stated,  2000-12-12+13:00 = 2000-12-12−11:00)
3.3.10.2 Lexical representation

For the following discussion, let the "date portion" of a dateTime or date object be an object similar to a dateTime or date object, with similar year, month, and day properties, but no others, having the same value for these properties as the original dateTime or date object.

The ·lexical space· of date consists of finite-length sequences of characters of the form: '-'? yyyy '-' mm '-' dd zzzzzz? where the date and optional timezone are represented exactly the same way as they are for dateTime.  The first moment of the interval is that represented by: '-' yyyy '-' mm '-' dd 'T00:00:00' zzzzzz? and the least upper bound of the interval is the timeline point represented (noncanonically) by: '-' yyyy '-' mm '-' dd 'T24:00:00' zzzzzz?.

Note: The ·recoverable timezone· of a date will always be a duration between '+12:00' and '11:59'.  Timezone lexical representations, as explained for dateTime, can range from '+14:00' to '-14:00'. The result is that literals of dates with very large or very negative timezones will map to a "normalized" date value with a ·recoverable timezone· different from that represented in the original representation, and a matching difference of +/- 1 day in the date itself.
3.3.10.3 Canonical representation

Given a member of the date ·value space·, the date portion of the ·canonical representation· (the entire representation for nontimezoned values, and all but the timezone representation for timezoned values) is always the date portion of the dateTime ·canonical representation· of the interval midpoint (the dateTime representation, truncated on the right to eliminate 'T' and all following characters). For timezoned values, append the canonical representation of the ·recoverable timezone·.

3.3.10.4 Lexical Mapping
The lexical representations for date are "projections" of those of dateTime, as follows:
Lexical Space
dateLexicalRep ::= yearFrag '-monthFrag '-dayFrag timezoneFrag?   Constraint:  Day-of-month Representations
Constraint: Day-of-month Representations
Within a dateLexicalRep, a dayFrag must not begin with the digit '3' or be '29' unless the value to which it would map would satisfy the value constraint on ·day· values ("Constraint: Day-of-month Values") given above.
The dateLexicalRep production is equivalent to this regular expression:

-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?

Note that neither the dateLexicalRep production nor this regular expression alone enforce the constraint on dateLexicalRep given above.

The ·lexical mapping· for date is ·dateLexicalMap·. The ·canonical mapping· is ·dateCanonicalMap·.

3.3.10.5 Facets

date has the following ·constraining facets·:

date and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

date has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from date may also specify values for the following ·constraining facets·:

date has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.3.11 gYearMonth

[Definition:]   gYearMonth represents a specific gregorian month in a specific gregorian year.  The ·value space· of gYearMonth is the set of Gregorian calendar months as defined in § 5.2.1 of [ISO 8601].  Specifically, it is a set of one-month long, non-periodic instances e.g. 1999-10 to represent the whole month of 1999-10, independent of how many days this month has.

gYearMonth represents specific whole Gregorian months in specific Gregorian years.

Since the lexical representation allows an optional time zone indicator, gYearMonth values are partially ordered because it may not be possible to unequivocally determine the order of two values one of which has a time zone and the other does not.  If gYearMonth values are considered as periods of time, the order relation on gYearMonth values is the order relation on their starting instants. This is discussed in Order relation on dateTime (§3.3.8.6).  See also Adding durations to dateTimes (§H).  Pairs of gYearMonth values with or without time zone indicators are totally ordered.

Note: Because month/year combinations in one calendar only rarely correspond to month/year combinations in other calendars, values of this type are not, in general, convertible to simple values corresponding to month/year combinations in other calendars.  This type should therefore be used with caution in contexts where conversion to other calendars is desired.
Note: See the conformance note in (§) which applies to the year part of this datatype as well.
3.3.11.1 Value Space

gYearMonth uses the date/timeSevenPropertyModel, with ·day·, ·hour·, ·minute·, and ·second· required to be absent·timezoneOffset· remains ·optional·.

Note: See the conformance note in Partial Implementation of Infinite Datatypes (§5.4) which applies to the ·year· value of this datatype.

Equality and order are as prescribed in The Seven-property Model (§D.2.1).

3.3.11.2 Lexical representationMapping

The lexical representation for gYearMonth is the reduced (right truncated) lexical representation for dateTime: CCYY-MM.  No left truncation is allowed.  An optional following time zone qualifier is allowed.  To accommodate year values outside the range from 0001 to 9999, additional digits can be added to the left of this representation and a preceding "-" sign is allowed.

For example, to indicate the month of May 1999, one would write: 1999-05. See also ISO 8601 Date and Time Formats (§G).

The lexical representations for gYearMonth are "projections" of those of dateTime, as follows:
Lexical Space
gYearMonthLexicalRep ::= yearFrag '-monthFrag timezoneFrag?
The gYearMonthLexicalRep is equivalent to this regular expression:

-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?

The ·lexical mapping· and ·canonical mapping· for gYearMonth are the following functions:
Lexical Mapping
Maps a gYearMonthLexicalRep to a gYearMonth value.
Canonical Mapping
Maps a gYearMonth value to a gYearMonthLexicalRep.
3.3.11.3 Constraining facets Facets

gYearMonth has the following ·constraining facets·:

gYearMonth and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

gYearMonth has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from gYearMonth may also specify values for the following ·constraining facets·:

gYearMonth has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.3.12 gYear

[Definition:]   gYear represents a gregorian calendar year.  The ·value space· of gYear is the set of Gregorian calendar years as defined in § 5.2.1 of [ISO 8601]. Specifically, it is a set of one-year long, non-periodic instances e.g. lexical 1999 to represent the whole year 1999, independent of how many months and days this year has.

gYear represents Gregorian calendar years.

Since the lexical representation allows an optional time zone indicator, gYear values are partially ordered because it may not be possible to unequivocally determine the order of two values one of which has a time zone and the other does not.  If gYear values are considered as periods of time, the order relation on gYear values is the order relation on their starting instants. This is discussed in Order relation on dateTime (§3.3.8.6).  See also Adding durations to dateTimes (§H).  Pairs of gYear values with or without time zone indicators are totally ordered.

Note: Because years in one calendar only rarely correspond to years in other calendars, values of this type are not, in general, convertible to simple values corresponding to years in other calendars.  This type should therefore be used with caution in contexts where conversion to other calendars is desired.
Note: See the conformance note in (§) which applies to the year part of this datatype as well.
3.3.12.1 Value Space

gYear uses the date/timeSevenPropertyModel, with ·month·, ·day·, ·hour·, ·minute·, and ·second· required to be absent·timezoneOffset· remains ·optional·.

Note: See the conformance note in Partial Implementation of Infinite Datatypes (§5.4) which applies to the ·year· value of this datatype.

Equality and order are as prescribed in The Seven-property Model (§D.2.1).

3.3.12.2 Lexical representationMapping

The lexical representation for gYear is the reduced (right truncated) lexical representation for dateTime: CCYY. No left truncation is allowed.  An optional following time zone qualifier is allowed as for dateTime.  To accommodate year values outside the range from 0001 to 9999, additional digits can be added to the left of this representation and a preceding "-" sign is allowed.

For example, to indicate 1999, one would write: 1999. See also ISO 8601 Date and Time Formats (§G).

The lexical representations for gYear are "projections" of those of dateTime, as follows:
Lexical Space
gYearLexicalRep ::= yearFrag timezoneFrag?
The gYearLexicalRep is equivalent to this regular expression:

-?([1-9][0-9]{3,}|0[0-9]{3})(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?

The ·lexical mapping· and ·canonical mapping· for gYear are the following functions:
Lexical Mapping
Maps a gYearLexicalRep to a gYear value.
Canonical Mapping
Maps a gYear value to a gYearLexicalRep.
3.3.12.3 Constraining facets Facets

gYear has the following ·constraining facets·:

gYear and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

gYear has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from gYear may also specify values for the following ·constraining facets·:

gYear has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.3.13 gMonthDay

[Definition:]   gMonthDay is a gregorian date that recurs, specifically a day of the year such as the third of May.  Arbitrary recurring dates are not supported by this datatype.  The ·value space· of gMonthDay is the set of calendar dates, as defined in § 3 of [ISO 8601].  Specifically, it is a set of one-day long, annually periodic instances.

gMonthDay represents whole calendar days that recur at the same point in each calendar year, or that occur in some arbitrary calendar year.  (Obviously, days beyond 28 cannot occur in all Februaries; 29 is nonetheless permitted.)

This datatype can be used, for example, to record birthdays; an instance of the datatype could be used to say that someone's birthday occurs on the 14th of September every year.

Since the lexical representation allows an optional time zone indicator, gMonthDay values are partially ordered because it may not be possible to unequivocally determine the order of two values one of which has a time zone and the other does not.  If gMonthDay values are considered as periods of time, in an arbitrary leap year, the order relation on gMonthDay values is the order relation on their starting instants. This is discussed in Order relation on dateTime (§3.3.8.6).  See also Adding durations to dateTimes (§H).  Pairs of gMonthDay values with or without time zone indicators are totally ordered.

Note: Because day/month combinations in one calendar only rarely correspond to day/month combinations in other calendars, values of this type do not, in general, have any straightforward or intuitive representation in terms of most other calendars. This type should therefore be used with caution in contexts where conversion to other calendars is desired.
3.3.13.1 Value Space

gMonthDay uses the date/timeSevenPropertyModel, with ·year·, ·hour·, ·minute·, and ·second· required to be absent·timezoneOffset· remains ·optional·.

Constraint: Day-of-month Values
The ·day· value must be no more than 30 if ·month· is one of 4, 6, 9, or 11, and no more than 29 if ·month· is 2.

Equality and order are as prescribed in The Seven-property Model (§D.2.1).

Note: In version 1.0 of this specification, gMonthDay values did not retain a time zone offset explicitly, but for time zone offsets not too far from ·UTC· their time zone offset could be recovered based on their value's first moment on the timeline.  The date/timeSevenPropertyModel retains all time zone offsets.
An example that shows the difference from version 1.0 (see Lexical representationMapping (§3.3.13.2) for the notations):
  • A day is a calendar (or "local time") day offset from ·UTC· by the appropriate interval; this is now true for all ·day· values, including those with time zone offsets outside the range +12:00 through -11:59 inclusive:
    --12-12+13:00 < --12-12+11:00  (just as --12-12+12:00 has always been less than --12-12+11:00, but in version 1.0  --12-12+13:00 > --12-12+11:00 , since --12-12+13:00's "recoverable time zone offset" was −11:00)
3.3.13.2 Lexical representationMapping

The lexical representation for gMonthDay is the left truncated lexical representation for date: --MM-DD. An optional following time zone qualifier is allowed as for date. No preceding sign is allowed.  No other formats are allowed. See also ISO 8601 Date and Time Formats (§G).

The lexical representations for gMonthDay are "projections" of those of dateTime, as follows:
Lexical Space
gMonthDayLexicalRep ::= '--monthFrag '-dayFrag timezoneFrag?   Constraint:  Day-of-month Representations
Constraint: Day-of-month Representations
Within a gMonthDayLexicalRep, a dayFrag must not begin with the digit '3' or be '29' unless the value to which it would map would satisfy the value constraint on ·day· values ("Constraint: Day-of-month Values") given above.
The gMonthDayLexicalRep is equivalent to this regular expression:

--(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?

Note that neither the gMonthDayLexicalRep production nor this regular expression alone enforce the constraint on gMonthDayLexicalRep given above.

This datatype can be used to represent a specific day in a month. To say, for example, that my birthday occurs on the 14th of September ever year.

The ·lexical mapping· and ·canonical mapping· for gMonthDay are the following functions:
Lexical Mapping
Maps a gMonthDayLexicalRep to a gMonthDay value.
Canonical Mapping
Maps a gMonthDay value to a gMonthDayLexicalRep.
3.3.13.3 Constraining facets Facets

gMonthDay has the following ·constraining facets·:

gMonthDay and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

gMonthDay has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from gMonthDay may also specify values for the following ·constraining facets·:

gMonthDay has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.3.14 gDay

[Definition:]   gDay is a gregorian day that recurs, specifically a day of the month such as the 5th of the month.  Arbitrary recurring days are not supported by this datatype.  The ·value space· of gDay is the space of a set of calendar dates as defined in § 3 of [ISO 8601].  Specifically, it is a set of one-day long, monthly periodic instances.

[Definition:]  gDay represents whole days within an arbitrary month—days that recur at the same point in each (Gregorian) month. This datatype can beis used to represent a specific day of the month. To say, for example, that I get my paycheckindicate, for example, that an employee gets a paycheck on the 15th of each month.  (Obviously, days beyond 28 cannot occur in all months; they are nonetheless permitted, up to 31.)

Since the lexical representation allows an optional time zone indicator, gDay values are partially ordered because it may not be possible to unequivocally determine the order of two values one of which has a time zone and the other does not.  If gDay values are considered as periods of time, in an arbitrary month that has 31 days, the order relation on gDay values is the order relation on their starting instants. This is discussed in Order relation on dateTime (§3.3.8.6).  See also Adding durations to dateTimes (§H).  Pairs of gDay values with or without time zone indicators are totally ordered.

Note: Because days in one calendar only rarely correspond to days in other calendars, gDay values of this type do not, in general, have any straightforward or intuitive representation in terms of most othernon-Gregorian calendars. This typegDay should therefore be used with caution in contexts where conversion to other calendars is desired.
3.3.14.1 Value Space

gDay uses the date/timeSevenPropertyModel, with ·year·, ·month·, ·hour·, ·minute·, and ·second· required to be absent·timezoneOffset· remains ·optional· and ·day· must be between 1 and 31 inclusive.

Equality and order are as prescribed in The Seven-property Model (§D.2.1).  Since gDay values (days) are ordered by their first moments, it is possible for apparent anomalies to appear in the order when ·timezoneOffset· values differ by at least 24 hours.  (It is possible for ·timezoneOffset· values to differ by up to 28 hours.)

Examples that may appear anomalous (see Lexical Mapping (§3.3.14.3) for the notations):
  • ---15 < ---16 , but  ---15−13:00 > ---16+13:00
  • ---15−11:00 = ---16+13:00
  • ---15−13:00 <> ---16 , because  ---15−13:00 > ---16+14:00  and ---15−13:00 < 16−14:00
Note: Time zone offsets do not cause wrap-around at the end of the month:  the last day of a given month with a time zone offset of −13:00 may start after the first day of the next month with offset +13:00, as measured on the global timeline, but nonetheless  ---01+13:00 < ---31−13:00 .
3.3.14.2 Lexical representation

The lexical representation for gDay is the left truncated lexical representation for date: ---DD . An optional following time zone qualifier is allowed as for date.  No preceding sign is allowed. No other formats are allowed.  See also ISO 8601 Date and Time Formats (§G).

3.3.14.3 Lexical Mapping
The lexical representations for gDay are "projections" of those of dateTime, as follows:
Lexical Space
gDayLexicalRep ::= '---dayFrag timezoneFrag?
The gDayLexicalRep is equivalent to this regular expression:

---(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?

The ·lexical mapping· for gDay is ·gDayLexicalMap·. The ·canonical mapping· is ·gDayCanonicalMap·.

3.3.14.4 constraining facets Facets

gDay has the following ·constraining facets·:

gDay and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

gDay has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from gDay may also specify values for the following ·constraining facets·:

gDay has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.3.15 gMonth

[Definition:]   gMonth is a gregorian month that recurs every year. The ·value space· of gMonth is the space of a set of calendar months as defined in § 3 of [ISO 8601].  Specifically, it is a set of one-month long, yearly periodic instances.

This datatype can be used to represent a specific month. To say, for example, that Thanksgiving falls in the month of November.gMonth represents whole (Gregorian) months within an arbitrary year—months that recur at the same point in each year.  It might be used, for example, to say what month annual Thanksgiving celebrations fall in different countries (--11 in the United States, --10 in Canada, and possibly other months in other countries).

Since the lexical representation allows an optional time zone indicator, gMonth values are partially ordered because it may not be possible to unequivocally determine the order of two values one of which has a time zone and the other does not.  If gMonth values are considered as periods of time, the order relation on gMonth is the order relation on their starting instants. This is discussed in Order relation on dateTime (§3.3.8.6).  See also Adding durations to dateTimes (§H).  Pairs of gMonth values with or without time zone indicators are totally ordered.

Note: Because months in one calendar only rarely correspond to months in other calendars, values of this type do not, in general, have any straightforward or intuitive representation in terms of most other calendars. This type should therefore be used with caution in contexts where conversion to other calendars is desired.
3.3.15.1 Value Space

gMonth uses the date/timeSevenPropertyModel, with ·year·, ·day·, ·hour·, ·minute·, and ·second· required to be absent·timezoneOffset· remains ·optional·.

Equality and order are as prescribed in The Seven-property Model (§D.2.1).

3.3.15.2 Lexical representationMapping

The lexical representation for gMonth is the left and right truncated lexical representation for date: --MM. An optional following time zone qualifier is allowed as for date.  No preceding sign is allowed. No other formats are allowed.  See also ISO 8601 Date and Time Formats (§G).

The lexical representations for gMonth are "projections" of those of dateTime, as follows:
Lexical Space
gMonthLexicalRep ::= '--monthFrag timezoneFrag?
The gMonthLexicalRep is equivalent to this regular expression:

--(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?

The ·lexical mapping· and ·canonical mapping· for gMonth are defined as follows:
Lexical Mapping
Maps a gMonthLexicalRep to a gMonth value.
Canonical Mapping
Maps a gMonth value to a gMonthLexicalRep.
3.3.15.3 Constraining facets Facets

gMonth has the following ·constraining facets·:

gMonth and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

gMonth has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from gMonth may also specify values for the following ·constraining facets·:

gMonth has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.3.16 hexBinary

[Definition:]  hexBinary represents arbitrary hex-encoded binary data. 

3.3.16.1 Value Space

The ·value space· of hexBinaryhexBinary is the set of possibly empty finite-length sequences of binary octets.  The length of a value is the number of octets.

3.3.16.2 Lexical RepresentationMapping

hexBinary has a ·lexical representation· where each binary octet is encoded as a character tuple, consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code. For example, '0FB7' is a hex encoding for the 16-bit integer 4023 (whose binary representation is 111110110111).

hexBinary's ·lexical space· consists of strings of hex (hexadecimal) digits, two consecutive digits representing each octet in the corresponding value (treating the octet as the binary representation of a number between 0 and 255).  For example, '0FB7' is a ·lexical representation· of the two-octet value 00001111 10110111.

More formally, the ·lexical space· of hexBinary is the set of literals matching the hexBinary production.
Lexical space of hexBinary
hexDigit ::= [0-9a-fA-F]
hexOctet ::= hexDigit hexDigit
hexBinary ::= hexOctet*

The set recognized by hexBinary is the same as that recognized by the regular expression '([0-9a-fA-F]{2})*'.

The ·canonical representation· for hexBinary is defined by prohibiting certain options from the Lexical RepresentationMapping (§3.3.16.2).  Specifically, the lower case hexadecimal digits ([a-f]) are not allowed.

3.3.16.3 Canonical Representation

The ·canonical representation· for hexBinary is defined by prohibiting certain options from the Lexical RepresentationMapping (§3.3.16.2).  Specifically, the lower case hexadecimal digits ([a-f]) are not allowed.

3.3.16.4 Constraining facets Facets

hexBinary has the following ·constraining facets·:

hexBinary and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

Datatypes derived by restriction from hexBinary may also specify values for the following ·constraining facets·:

hexBinary has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.3.17 base64Binary

[Definition:]   base64Binary represents arbitrary Base64-encoded arbitrary binary data.  The ·value space· of base64Binary is the set of finite-length sequences of binary octets. For base64Binary data the entire binary stream is encoded using the Base64 Alphabet in [RFC 2045]Encoding defined in [RFC 3548], which is derived from the encoding described in [RFC 2045].

3.3.17.1 Value Space

The ·value space· of base64Binary is the set of possibly empty finite-length sequences of binary octets.  The length of a value is the number of octets.

3.3.17.2 Lexical Mapping

The lexical forms·lexical representations· of base64Binarybase64Binary values are limited to the 65 characters of the Base64 Alphabet defined in [RFC 2045][RFC 3548], i.e., a-z, A-Z, 0-9, the plus sign (+), the forward slash (/) and the equal sign (=), together with the characters defined in [XML] as white spacethe space character (#x20). No other characters are allowed.

For compatibility with older mail gateways, [RFC 2045] suggests that bBase64 data should have lines limited to at most 76 characters in length.  This line-length limitation is not required by [RFC 3548] and is not mandated in the lexical forms·lexical representations· of base64Binarybase64Binary data and .  It must notmust not be enforced by XML Schema processors.

The ·lexical space· of base64Binarybase64Binary is given by the following grammar (the notation is that used in [XML]); legal lexical forms must matchthe set of literals which ·match· the base64Binarybase64Binaryproduction.

Base64Binary  ::=  ((B64S B64S B64S B64S)*
                     ((B64S B64S B64S B64) |
                      (B64S B64S B16S '=') |
                      (B64S B04S '=' #x20? '=')))?

B64S         ::= B64 #x20?

B16S         ::= B16 #x20?

B04S         ::= B04 #x20?


B04         ::=  [AQgw]
B16         ::=  [AEIMQUYcgkosw048]
B64         ::=  [A-Za-z0-9+/]

Lexical space of base64Binary
Base64Binary ::= (B64quad* B64final)?
B64quad ::= (B64 B64 B64 B64)
/* B64quad represents three octets of binary data. */
B64final ::= B64finalquad | Padded16 | Padded8
B64finalquad ::= (B64 B64 B64 B64char)
/* B64finalquad represents three octets of binary data without trailing space. */
Padded16 ::= B64 B64 B16 '='
/* Padded16 represents a two-octet at the end of the data. */
Padded8 ::= B64 B04 '=' #x20? '='
/* Padded8 represents a single octet at the end of the data. */
B64 ::= B64char #x20?
B64char ::= [A-Za-z0-9+/]
B16 ::= B16char #x20?
B16char ::= [AEIMQUYcgkosw048]
/* Base64 characters whose bit-string value ends in '00' */
B04 ::= B04char #x20?
B04char ::= [AQgw]
/* Base64 characters whose bit-string value ends in '0000' */
The Base64Binary production is equivalent to the following regular expression.

((([A-Za-z0-9+/] ?){4})*(([A-Za-z0-9+/] ?){3}[A-Za-z0-9+/]|([A-Za-z0-9+/] ?){2}[AEIMQUYcgkosw048] ?=|[A-Za-z0-9+/] ?[AQgw] ?= ?=))?

Note that each '?' except the last is preceded by a single space character.

Note that this grammar requires the number of non-whitespace characters in the lexical form·lexical representation· to be a multiple of four, and for equals signs to appear only at the end of the lexical form·lexical representation·; stringsliterals which do not meet these constraints are not legal lexical forms·lexical representations· of base64Binarybase64Binary because they cannot successfully be decoded by base64 decoders.

Note: The above definition of the ·lexical space· is more restrictive than that given in [RFC 2045] as regards whitespace — and less restrictive than [RFC 3548]. thisThis is not an issue in practice.  Any string compatible with theeither RFC can occur in an element or attribute validated by this type, because the ·whiteSpace· facet of this type is fixed to collapse, which means that all leading and trailing whitespace will be stripped, and all internal whitespace collapsed to single space characters, before the above grammar is enforced. The possibility of ignoring whitespace in Base64 data is foreseen in clause 2.3 of [RFC 3548], but for the reasons given there this specification does not allow implementations to ignore non-whitespace characters which are not in the Base64 Alphabet.

The canonical lexical form·lexical representation· of a base64Binarybase64Binary data value is the bBase64 encoding of the value which matches the Canonical-base64Binary production in the following grammar:

Canonical-base64Binary  ::=  (B64 B64 B64 B64)*
                               ((B64 B64 B16 '=') | (B64 B04 '=='))?

Canonical representation of base64Binary
Canonical-base64Binary ::= CanonicalQuad* CanonicalPadded?
CanonicalQuad ::= B64char B64char B64char B64char
CanonicalPadded ::= B64char B64char B16char '=' | B64char B04char '=='

That is, the ·canonical representation· of a base64Binary value is the ·lexical representation· which maps to that value and contains no whitespace. The ·canonical mapping· for base64Binary is thus the encoding algorithm for Base64 data given in [RFC 2045] and [RFC 3548], with the proviso that no characters except those in the Base64 Alphabet are to be written out.

Note: For some values the ·canonical formrepresentation· defined above does not conform to [RFC 2045], which requires breaking with linefeeds at appropriate intervals. It does conform with [RFC 3548].

The length of a base64Binarybase64Binary value is the number of octets it contains.  This may be calculated from the lexical form·lexical representation· by removing whitespace and padding characters and performing the calculation shown in the pseudo-code below:

lex2   := killwhitespace(lexform)    -- remove whitespace characters
lex3   := strip_equals(lex2)         -- strip padding characters at end
length := floor (length(lex3) * 3 / 4)         -- calculate length

Note on encoding:  [RFC 2045] and [RFC 3548] explicitly references US-ASCII encoding.  However, decoding of base64Binary data in an XML entity is to be performed on the Unicode characters obtained after character encoding processing as specified by [XML].

3.3.17.3 Constraining facets Facets

base64Binary has the following ·constraining facets·:

base64Binary and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

Datatypes derived by restriction from base64Binary may also specify values for the following ·constraining facets·:

base64Binary has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.3.18 anyURI

[Definition:]   anyURI represents a Uniform Resource Identifier Reference (URI)an Internationalized Resource Identifier Reference (IRI).  An anyURI value can be absolute or relative, and may have an optional fragment identifier (i.e., it may be a URIan IRI Reference).  This type should be used to specify the intention thatwhen the value fulfills the role of a URI as defined by [RFC 2396], as amended by [RFC 2732]an IRI, as defined in [RFC 3987] or its successor(s) in the IETF Standards Track.

Note: IRIs may be used to locate resources or simply to identify them. In the case where they are used to locate resources using a URI, applications should use theThe mapping from anyURIanyURI values to URIs is as definedgiven by the URI reference escaping procedure defined in Section 5.4 Locator Attribute of [XML Linking Language] (see also Section 8 Character Encoding in URI References of [Character Model])Section 3.1 Mapping of IRIs to URIs of [RFC 3987] or its successor(s) in the IETF Standards Track.  This means that a wide range of internationalized resource identifiers can be specified when an anyURIanyURI is called for, and still be understood as URIs per [RFC 2396], as amended by [RFC 2732], where appropriate to identify resources[RFC 3986] and its successor(s).
Note: Section 5.4 Locator Attribute of [XML Linking Language] requires that relative URI references be absolutized as defined in [XML Base] before use.  This is an XLink-specific requirement and is not appropriate for XML Schema, since neither the ·lexical space· nor the ·value space· of the anyURI type are restricted to absolute URIs.  Accordingly absolutization must not be performed by schema processors as part of schema validation.
Note: Each URI scheme imposes specialized syntax rules for URIs in that scheme, including restrictions on the syntax of allowed fragment identifiers. Because it is impractical for processors to check that a value is a context-appropriate URI reference, this specification follows the lead of [RFC 2396] (as amended by [RFC 2732]) in this matter: such rules and restrictions are not part of type validity and are not checked by ·minimally conforming· processors. Thus in practice the above definition imposes only very modest obligations on ·minimally conforming· processors.
3.3.18.1 Lexical representationMapping

The ·lexical space· of anyURIanyURI is the set of possibly empty finite-length character sequences which, when the algorithm defined in Section 5.4 of [XML Linking Language] is applied to them, result in strings which are legal URIs according to [RFC 2396], as amended by [RFC 2732].

Note: For an anyURI value to be usable in practice as an IRI, the result of applying to it the algorithm defined in Section 3.1 of [RFC 3987] should be a string which is a legal URI according to [RFC 3986]. (This is true at the time this document is published; if in the future [RFC 3987] and [RFC 3986] are replaced by other specifications in the IETF Standards Track, the relevant constraints will be those imposed by those successor specifications.)
Each URI scheme imposes specialized syntax rules for URIs in that scheme, including restrictions on the syntax of allowed fragment identifiers. Because it is impractical for processors to check that a value is a context-appropriate URI reference, neither the syntactic constraints defined by the definitions of individual schemes nor the generic syntactic constraints defined by [RFC 3987] and [RFC 3986] and their successors are part of this datatype as defined here. Applications which depend on anyURI values being legal according to the rules of the relevant specifications should make arrangements to check values against the appropriate definitions of IRI, URI, and specific schemes.
Note: Spaces are, in principle, allowed in the ·lexical space· of anyURIanyURI, however, their use is highly discouraged (unless they are encoded by '%20').

The ·lexical mapping· for anyURI is the identity mapping.

Note: The definitions of URI in the current IETF specifications define certain URIs as equivalent to each other. Those equivalences are not part of this datatype as defined here: if two "equivalent" URIs or IRIs are different character sequences, they map to different values in this datatype.
3.3.18.2 Constraining facets Facets

anyURI has the following ·constraining facets·:

anyURI and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

Datatypes derived by restriction from anyURI may also specify values for the following ·constraining facets·:

anyURI has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.3.19 QName

[Definition:]   QName represents XML qualified names. The ·value space· of QName is the set of tuples {namespace name, local part}, where namespace name is an anyURI and local part is an NCName. The ·lexical space· of QName is the set of strings that ·match· the QName production of [Namespaces in XML].

It is ·implementation-defined· whether an implementation of this specification supports the QName production from [Namespaces in XML], or that from [Namespaces in XML 1.0], or both. See Dependencies on Other Specifications (§1.3).

The mapping from lexical space to value space for a particular QName ·literal· depends on the namespace bindings in scope where the literal occurs.

When QNames appear in an XML context, the bindings to be used in the ·lexical mapping· are those in the [in-scope namespaces] property of the relevant element. When this datatype is used in a non-XML host language, the host language must specify what namespace bindings are to be used.

The host language, whether XML-based or otherwise, may specify whether unqualified names are bound to the default namespace (if any) or not; the host language may also place this under user control. If the host language does not specify otherwise, unqualified names are bound to the default namespace.

Note: The default treatment of unqualified names parallels that specified in [Namespaces in XML] for element names (as opposed to that specified for attribute names).
Note: The mapping between ·literals· in the ·lexical space· and values in the ·value space· of QNameQName requires a namespace declaration to be in scope for the context in which QNameQName is used. 
Because the lexical representations available for any value of type QName vary with context, no ·canonical representation· is defined for QName in this specification.
3.3.19.1 Constraining facets Facets

QName has the following ·constraining facets·:

QName and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

Datatypes derived by restriction from QName may also specify values for the following ·constraining facets·:

QName has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

The use of ·length·, ·minLength· and ·maxLength· on QName or datatypes derived from QName is deprecated. These facets are meaningless for these datatypes, and all instances are facet-valid with respect to them. Future versions of this specification may remove these facets for thisthese datatypes.

3.3.20 NOTATION

[Definition:]  NOTATION represents the NOTATION attribute type from [XML]. The ·value space· of NOTATION is the set of QNames of notations declared in the current schema. The ·lexical space· of NOTATION is the set of all names of notations declared in the current schema (in the form of QNames).

Note: Because its ·value space· depends on the notion of a "current schema", as instantiated for example by [XSD 1.1 Part 1: Structures], the NOTATION datatype is unsuitable for use in other contexts which lack the notion of a current schema.

The lexical mapping rules for NOTATION are as given for QName in QName (§3.3.19).

Schema Component Constraint: enumeration facet value required for NOTATION
It is an ·error· for NOTATIONNOTATION to be used directly in a schema.  Only datatypes that are derived from NOTATIONNOTATION by specifying a value for ·enumeration· can be used in a schema.

For compatibility (see Terminology (§1.6)) NOTATIONNOTATION should be used only on attributes and should only be used in schemas with no target namespace.

Note: Because the lexical representations available for any given value of NOTATION vary with context, this specification defines no ·canonical representation· for NOTATION values.
3.3.20.1 Constraining facets Facets

NOTATION has the following ·constraining facets·:

NOTATION and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

Datatypes derived by restriction from NOTATION may also specify values for the following ·constraining facets·:

NOTATION has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

The use of ·length·, ·minLength· and ·maxLength· on NOTATION or datatypes derived from NOTATION is deprecated.  Future versions of this specification may remove these facets for this datatype.

previous sub-section 3.4 Derived datatypesOther Built-in Datatypes

        3.4.1 normalizedString
            3.4.1.1 Constraining facets Facets
            3.4.1.2 Derived datatypes
        3.4.2 token
            3.4.2.1 Constraining facets Facets
            3.4.2.2 Derived datatypes
        3.4.3 language
            3.4.3.1 Constraining facets Facets
        3.4.4 NMTOKEN
            3.4.4.1 Constraining facets Facets
            3.4.4.2 DerivedRelated datatypes
        3.4.5 NMTOKENS
            3.4.5.1 Constraining facets Facets
        3.4.6 Name
            3.4.6.1 Constraining facets Facets
            3.4.6.2 Derived datatypes
        3.4.7 NCName
            3.4.7.1 Constraining facets Facets
            3.4.7.2 Derived datatypes
        3.4.8 ID
            3.4.8.1 Constraining facets Facets
        3.4.9 IDREF
            3.4.9.1 Constraining facets Facets
            3.4.9.2 DerivedRelated datatypes
        3.4.10 IDREFS
            3.4.10.1 Constraining facets Facets
        3.4.11 ENTITY
            3.4.11.1 Constraining facets Facets
            3.4.11.2 DerivedRelated datatypes
        3.4.12 ENTITIES
            3.4.12.1 Constraining facets Facets
        3.4.13 integer
            3.4.13.1 Lexical representation
            3.4.13.2 Canonical representation
            3.4.13.3 Constraining facetsFacets
            3.4.13.4 Derived datatypes
        3.4.14 nonPositiveInteger
            3.4.14.1 Lexical representation
            3.4.14.2 Canonical representation
            3.4.14.3 Constraining facets Facets
            3.4.14.4 Derived datatypes
        3.4.15 negativeInteger
            3.4.15.1 Lexical representation
            3.4.15.2 Canonical representation
            3.4.15.3 Constraining facets Facets
        3.4.16 long
            3.4.16.1 Lexical Representation
            3.4.16.2 Canonical Representation
            3.4.16.3 Constraining facets Facets
            3.4.16.4 Derived datatypes
        3.4.17 int
            3.4.17.1 Lexical Representation
            3.4.17.2 Canonical representation
            3.4.17.3 Constraining facets Facets
            3.4.17.4 Derived datatypes
        3.4.18 short
            3.4.18.1 Lexical representation
            3.4.18.2 Canonical representation
            3.4.18.3 Constraining facets Facets
            3.4.18.4 Derived datatypes
        3.4.19 byte
            3.4.19.1 Lexical representation
            3.4.19.2 Canonical representation
            3.4.19.3 Constraining facets Facets
        3.4.20 nonNegativeInteger
            3.4.20.1 Lexical representation
            3.4.20.2 Canonical representation
            3.4.20.3 Constraining facets Facets
            3.4.20.4 Derived datatypes
        3.4.21 unsignedLong
            3.4.21.1 Lexical representation
            3.4.21.2 Canonical representation
            3.4.21.3 Constraining facets Facets
            3.4.21.4 Derived datatypes
        3.4.22 unsignedInt
            3.4.22.1 Lexical representation
            3.4.22.2 Canonical representation
            3.4.22.3 Constraining facets Facets
            3.4.22.4 Derived datatypes
        3.4.23 unsignedShort
            3.4.23.1 Lexical representation
            3.4.23.2 Canonical representation
            3.4.23.3 Constraining facets Facets
            3.4.23.4 Derived datatypes
        3.4.24 unsignedByte
            3.4.24.1 Lexical representation
            3.4.24.2 Canonical representation
            3.4.24.3 Constraining facets Facets
        3.4.25 positiveInteger
            3.4.25.1 Lexical representation
            3.4.25.2 Canonical representation
            3.4.25.3 Constraining facets Facets
        3.4.26 yearMonthDuration
            3.4.26.1 The Lexical Mapping
            3.4.26.2 Facets
        3.4.27 dayTimeDuration
            3.4.27.1 The Lexical Space
            3.4.27.2 Facets
        3.4.28 dateTimeStamp
            3.4.28.1 The Lexical Space
            3.4.28.2 Facets

This section gives conceptual definitions for all ·built-in· ·derived··ordinary· datatypes defined by this specification. The XML representation used to define ·derived· ·ordinary· datatypes (whether ·built-in· or ·user-derived··user-defined·) is given in section XML Representation of Simple Type Definition Schema Components (§4.1.2) and the complete definitions of the ·built-in· ·derived··ordinary· datatypes are provided in Appendix Athe appendix Schema for Schema Documents (Datatypes) Datatype Definitions (normative) (§A).

3.4.1 normalizedString

[Definition:]   normalizedString represents white space normalized strings.  The ·value space· of normalizedString is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters.  The ·lexical space· of normalizedString is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters.  The ·base type· of normalizedString is string.

3.4.1.1 Constraining facets Facets

normalizedString has the following ·constraining facets·:

normalizedString has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from normalizedString may also specify values for the following ·constraining facets·:

normalizedString has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false
3.4.1.2 Derived datatypes

The following ·built-in· datatype is ·derived· from normalizedString

3.4.2 token

[Definition:]   token represents tokenized strings. The ·value space· of token is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters, that have no leading or trailing spaces (#x20) and that have no internal sequences of two or more spaces. The ·lexical space· of token is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters, that have no leading or trailing spaces (#x20) and that have no internal sequences of two or more spaces. The ·base type· of token is normalizedString.

3.4.2.1 Constraining facets Facets

token has the following ·constraining facets·:

token has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from token may also specify values for the following ·constraining facets·:

token has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false
3.4.2.2 Derived datatypes

The following ·built-in· datatypes are ·derived· from token

3.4.3 language

[Definition:]  language represents formal natural language identifiers, as defined by [RFC 3066][BCP 47] (currently represented by [RFC 4646] and [RFC 4647]) or its successor(s). The ·value space· of language is the set of all strings that are valid language identifiers as defined [RFC 3066]The ·value space· and ·lexical space· of languagelanguage isare the set of all strings that conform to the pattern

[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*

This is the set of strings accepted by the grammar given in [RFC 3066], which is now obsolete; the current specification of language codes is more restrictive.  The ·base type· of languagelanguage is token.
Note: The regular expression above provides the only normative constraint on the lexical and value spaces of this type. The additional constraints imposed on language identifiers by [BCP 47] and its successor(s), and in particular their requirement that language codes be registered with IANA or ISO if not given in ISO 639, are not part of this datatype as defined here.
Note: [BCP 47] specifies that language codes "are to be treated as case insensitive; there exist conventions for capitalization of some of the subtags, but these MUST NOT be taken to carry meaning." Since the language datatype is derived from string, it inherits from string a one-to-one mapping from lexical representations to values. The literals 'MN' and 'mn' (for Mongolian) therefore correspond to distinct values and have distinct canonical forms. Users of this specification should be aware of this fact, the consequence of which is that the case-insensitive treatment of language values prescribed by [BCP 47] does not follow from the definition of this datatype given here; applications which require case-insensitivity should make appropriate adjustments.
Note: The empty string is not a member of the ·value space· of language. Some constructs which normally take language codes as their values, however, also allow the empty string. The attribute xml:lang defined by [XML] is one example; there, the empty string overrides a value which would otherwise be inherited, but without specifying a new value.
One way to define the desired set of possible values is illustrated by the schema document for the XML namespace at http://www.w3.org/2001/xml.xsd, which defines the attribute xml:lang as having a type which is a union of language and an anonymous type whose only value is the empty string:
 <xs:attribute name="lang">
   <xs:annotation>
     <xs:documentation>
       See RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt 
       and the IANA registry at 
       http://www.iana.org/assignments/lang-tag-apps.htm for
       further information.

       The union allows for the 'un-declaration' of xml:lang with
       the empty string.
     </xs:documentation>
   </xs:annotation>
   <xs:simpleType>
     <xs:union memberTypes="xs:language">
       <xs:simpleType>    
         <xs:restriction base="xs:string">
           <xs:enumeration value=""/>
         </xs:restriction>
       </xs:simpleType>
     </xs:union>
   </xs:simpleType>
 </xs:attribute>
3.4.3.1 Constraining facets Facets

language has the following ·constraining facets·:

language has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from language may also specify values for the following ·constraining facets·:

language has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.4.4 NMTOKEN

[Definition:]   NMTOKEN represents the NMTOKEN attribute type from [XML]. The ·value space· of NMTOKEN is the set of tokens that ·match· the Nmtoken production in [XML]. The ·lexical space· of NMTOKEN is the set of strings that ·match· the Nmtoken production in [XML].  The ·base type· of NMTOKEN is token.

It is ·implementation-defined· whether an implementation of this specification supports the NMTOKEN production from [XML], or that from [XML 1.0], or both. See Dependencies on Other Specifications (§1.3).

For compatibility (see Terminology (§1.6) NMTOKENNMTOKEN should be used only on attributes.

3.4.4.1 Constraining facets Facets

NMTOKEN has the following ·constraining facets·:

NMTOKEN has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from NMTOKEN may also specify values for the following ·constraining facets·:

NMTOKEN has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false
3.4.4.2 DerivedRelated datatypes

The following ·built-in· datatype is ·constructed· from NMTOKEN

3.4.5 NMTOKENS

[Definition:]  NMTOKENS represents the NMTOKENS attribute type from [XML]. The ·value space· of NMTOKENS is the set of finite, non-zero-length sequences of ·NMTOKEN·s.  The ·lexical space· of NMTOKENS is the set of space-separated lists of tokens, of which each token is in the ·lexical space· of NMTOKEN.  The ·item type· of NMTOKENS is NMTOKEN.

For compatibility (see Terminology (§1.6)) NMTOKENSNMTOKENS should be used only on attributes.

3.4.5.1 Constraining facets Facets

NMTOKENS has the following ·constraining facets·:

NMTOKENS has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from NMTOKENS may also specify values for the following ·constraining facets·:

NMTOKENS has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.4.6 Name

[Definition:]   Name represents XML Names. The ·value space· of Name is the set of all strings which ·match· the Name production of [XML].  The ·lexical space· of Name is the set of all strings which ·match· the Name production of [XML]. The ·base type· of Name is token.

It is ·implementation-defined· whether an implementation of this specification supports the Name production from [XML], or that from [XML 1.0], or both. See Dependencies on Other Specifications (§1.3).

3.4.6.1 Constraining facets Facets

Name has the following ·constraining facets·:

Name has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from Name may also specify values for the following ·constraining facets·:

Name has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false
3.4.6.2 Derived datatypes

The following ·built-in· datatype is ·derived· from Name

3.4.7 NCName

[Definition:]   NCName represents XML "non-colonized" Names.  The ·value space· of NCName is the set of all strings which ·match· the NCName production of [Namespaces in XML].  The ·lexical space· of NCName is the set of all strings which ·match· the NCName production of [Namespaces in XML].  The ·base type· of NCName is Name.

It is ·implementation-defined· whether an implementation of this specification supports the NCName production from [Namespaces in XML], or that from [Namespaces in XML 1.0], or both. See Dependencies on Other Specifications (§1.3).

3.4.7.1 Constraining facets Facets

NCName has the following ·constraining facets·:

NCName has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from NCName may also specify values for the following ·constraining facets·:

NCName has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false
3.4.7.2 Derived datatypes

The following ·built-in· datatypes are ·derived· from NCName

3.4.8 ID

[Definition:]  ID represents the ID attribute type from [XML].  The ·value space· of ID is the set of all strings that ·match· the NCName production in [Namespaces in XML].  The ·lexical space· of ID is the set of all strings that ·match· the NCName production in [Namespaces in XML]. The ·base type· of ID is NCName.

Note: It is ·implementation-defined· whether an implementation of this specification supports the NCName production from [Namespaces in XML], or that from [Namespaces in XML 1.0], or both. See Dependencies on Other Specifications (§1.3).

For compatibility (see Terminology (§1.6)), IDID should be used only on attributes.

Note: Uniqueness of items validated as ID is not part of this datatype as defined here. When this specification is used in conjunction with [XSD 1.1 Part 1: Structures], uniqueness is enforced at a different level, not as part of datatype validity; see Validation Rule: Validation Root Valid (ID/IDREF) in [XSD 1.1 Part 1: Structures].
3.4.8.1 Constraining facets Facets

ID has the following ·constraining facets·:

ID has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from ID may also specify values for the following ·constraining facets·:

ID has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.4.9 IDREF

[Definition:]   IDREF represents the IDREF attribute type from [XML].  The ·value space· of IDREF is the set of all strings that ·match· the NCName production in [Namespaces in XML].  The ·lexical space· of IDREF is the set of strings that ·match· the NCName production in [Namespaces in XML]. The ·base type· of IDREF is NCName.

Note: It is ·implementation-defined· whether an implementation of this specification supports the NCName production from [Namespaces in XML], or that from [Namespaces in XML 1.0], or both. See Dependencies on Other Specifications (§1.3).

For compatibility (see Terminology (§1.6)) this datatype should be used only on attributes.

Note: Existence of referents for items validated as IDREF is not part of this datatype as defined here. When this specification is used in conjunction with [XSD 1.1 Part 1: Structures], referential integrity is enforced at a different level, not as part of datatype validity; see Validation Rule: Validation Root Valid (ID/IDREF) in [XSD 1.1 Part 1: Structures].
3.4.9.1 Constraining facets Facets

IDREF has the following ·constraining facets·:

IDREF has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from IDREF may also specify values for the following ·constraining facets·:

IDREF has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false
3.4.9.2 DerivedRelated datatypes

The following ·built-in· datatype is ·constructed· from IDREF

3.4.10 IDREFS

[Definition:]   IDREFS represents the IDREFS attribute type from [XML].  The ·value space· of IDREFS is the set of finite, non-zero-length sequences of IDREFs. The ·lexical space· of IDREFS is the set of space-separated lists of tokens, of which each token is in the ·lexical space· of IDREF.  The ·item type· of IDREFS is IDREFS.

For compatibility (see Terminology (§1.6)) IDREFSIDREFS should be used only on attributes.

Note: Existence of referents for items validated as IDREFS is not part of this datatype as defined here. When this specification is used in conjunction with [XSD 1.1 Part 1: Structures], referential integrity is enforced at a different level, not as part of datatype validity; see Validation Rule: Validation Root Valid (ID/IDREF) in [XSD 1.1 Part 1: Structures].
3.4.10.1 Constraining facets Facets

IDREFS has the following ·constraining facets·:

IDREFS has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from IDREFS may also specify values for the following ·constraining facets·:

IDREFS has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.4.11 ENTITY

[Definition:]   ENTITY represents the ENTITY attribute type from [XML].  The ·value space· of ENTITY is the set of all strings that ·match· the NCName production in [Namespaces in XML] and have been declared as an unparsed entity in a document type definition. The ·lexical space· of ENTITY is the set of all strings that ·match· the NCName production in [Namespaces in XML]. The ·base type· of ENTITY is NCName.

Note: It is ·implementation-defined· whether an implementation of this specification supports the NCName production from [Namespaces in XML], or that from [Namespaces in XML 1.0], or both. See Dependencies on Other Specifications (§1.3).
Note: The ·value space· of ENTITYENTITY is scoped to a specific instance document.

For compatibility (see Terminology (§1.6)) ENTITYENTITY should be used only on attributes.

3.4.11.1 Constraining facets Facets

ENTITY has the following ·constraining facets·:

ENTITY has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from ENTITY may also specify values for the following ·constraining facets·:

ENTITY has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false
3.4.11.2 DerivedRelated datatypes

The following ·built-in· datatype is ·constructed· from ENTITY

3.4.12 ENTITIES

[Definition:]  ENTITIES represents the ENTITIES attribute type from [XML].  The ·value space· of ENTITIES is the set of finite, non-zero-length sequences of ·ENTITY·s that have been declared as unparsed entities in a document type definition.  The ·lexical space· of ENTITIES is the set of space-separated lists of tokens, of which each token is in the ·lexical space· of ENTITY.  The ·item type· of ENTITIES is .

Note: The ·value space· of ENTITIESENTITIES is scoped to a specific instance document.

For compatibility (see Terminology (§1.6)) ENTITIESENTITIES should be used only on attributes.

3.4.12.1 Constraining facets Facets

ENTITIES has the following ·constraining facets·:

ENTITIES has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from ENTITIES may also specify values for the following ·constraining facets·:

ENTITIES has the following values for its ·fundamental facets·:

  • ordered = false
  • bounded = false
  • cardinality = countably infinite
  • numeric = false

3.4.13 integer

[Definition:]   integer is derived from decimal by fixing the value of ·fractionDigits· to be 0 and disallowing the trailing decimal point.  This results in the standard mathematical concept of the integer numbers.  The ·value space· of integer is the infinite set {...,-2,-1,0,1,2,...}.  The ·base type· of integer is decimal.

3.4.13.1 Lexical representation

integerinteger has a lexical representation consisting of a finite-length sequence of one or more decimal digits (#x30-#x39) with an optional leading sign.  If the sign is omitted, "+" is assumed.  For example: -1, 0, 12678967543233, +100000.

3.4.13.2 Canonical representation

The ·canonical representation· for integerinteger is defined by prohibiting certain options from the Lexical representation (§3.4.13.1).  Specifically, the preceding optional "+" sign is prohibited and leading zeroes are prohibited.

3.4.13.3 Constraining facetsFacets

integer has the following ·constraining facets·:

integer and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

integer has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from integer may also specify values for the following ·constraining facets·:

integer has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = false
  • cardinality = countably infinite
  • numeric = true
3.4.13.4 Derived datatypes

The following ·built-in· datatypes are ·derived· from integer

3.4.14 nonPositiveInteger

[Definition:]   nonPositiveInteger is derived from integer by setting the value of ·maxInclusive· to be 0.  This results in the standard mathematical concept of the non-positive integers. The ·value space· of nonPositiveInteger is the infinite set {...,-2,-1,0}.  The ·base type· of nonPositiveInteger is integer.

3.4.14.1 Lexical representation

nonPositiveIntegernonPositiveInteger has a lexical representation consisting of an optional preceding sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39).  The sign may be "+" or may be omitted only for lexical forms denoting zero; in all other lexical forms, the negative sign ('-') must be present.  For example: -1, 0, -12678967543233, -100000.

3.4.14.2 Canonical representation

The ·canonical representation· for nonPositiveIntegernonPositiveInteger is defined by prohibiting certain options from the Lexical representation (§3.4.14.1).  In the canonical form for zero, the sign must be omitted.  Leading zeroes are prohibited.

3.4.14.3 Constraining facets Facets

nonPositiveInteger has the following ·constraining facets·:

nonPositiveInteger and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

nonPositiveInteger has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from nonPositiveInteger may also specify values for the following ·constraining facets·:

nonPositiveInteger has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = false
  • cardinality = countably infinite
  • numeric = true
3.4.14.4 Derived datatypes

The following ·built-in· datatype is ·derived· from nonPositiveInteger

3.4.15 negativeInteger

[Definition:]   negativeInteger is derived from nonPositiveInteger by setting the value of ·maxInclusive· to be -1.  This results in the standard mathematical concept of the negative integers.  The ·value space· of negativeInteger is the infinite set {...,-2,-1}.  The ·base type· of negativeInteger is nonPositiveInteger.

3.4.15.1 Lexical representation

negativeIntegernegativeInteger has a lexical representation consisting of a negative sign ('-') followed by a non-empty finite-length sequence of decimal digits (#x30-#x39).  For example: -1, -12678967543233, -100000.

3.4.15.2 Canonical representation

The ·canonical representation· for negativeIntegernegativeInteger is defined by prohibiting certain options from the Lexical representation (§3.4.15.1).  Specifically, leading zeroes are prohibited.

3.4.15.3 Constraining facets Facets

negativeInteger has the following ·constraining facets·:

negativeInteger and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

negativeInteger has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from negativeInteger may also specify values for the following ·constraining facets·:

negativeInteger has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = false
  • cardinality = countably infinite
  • numeric = true

3.4.16 long

[Definition:]   long is derived from integer by setting the value of ·maxInclusive· to be 9223372036854775807 and ·minInclusive· to be -9223372036854775808. The ·base type· of long is integer.

3.4.16.1 Lexical Representation

longlong has a lexical representation consisting of an optional sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39).  If the sign is omitted, "+" is assumed.  For example: -1, 0, 12678967543233, +100000.

3.4.16.2 Canonical Representation

The ·canonical representation· for longlong is defined by prohibiting certain options from the Lexical Representation (§3.4.16.1).  Specifically, the the optional "+" sign is prohibited and leading zeroes are prohibited.

3.4.16.3 Constraining facets Facets

long has the following ·constraining facets·:

long and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

long has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from long may also specify values for the following ·constraining facets·:

long has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = true
  • cardinality = finite
  • numeric = true
3.4.16.4 Derived datatypes

The following ·built-in· datatype is ·derived· from long

3.4.17 int

[Definition:]   int is derived from long by setting the value of ·maxInclusive· to be 2147483647 and ·minInclusive· to be -2147483648.  The ·base type· of int is long.

3.4.17.1 Lexical Representation

intint has a lexical representation consisting of an optional sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39).  If the sign is omitted, "+" is assumed. For example: -1, 0, 126789675, +100000.

3.4.17.2 Canonical representation

The ·canonical representation· for intint is defined by prohibiting certain options from the Lexical Representation (§3.4.17.1).  Specifically, the the optional "+" sign is prohibited and leading zeroes are prohibited.

3.4.17.3 Constraining facets Facets

int has the following ·constraining facets·:

int and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

int has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from int may also specify values for the following ·constraining facets·:

int has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = true
  • cardinality = finite
  • numeric = true
3.4.17.4 Derived datatypes

The following ·built-in· datatype is ·derived· from int

3.4.18 short

[Definition:]   short is derived from int by setting the value of ·maxInclusive· to be 32767 and ·minInclusive· to be -32768.  The ·base type· of short is int.

3.4.18.1 Lexical representation

shortshort has a lexical representation consisting of an optional sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39).  If the sign is omitted, "+" is assumed. For example: -1, 0, 12678, +10000.

3.4.18.2 Canonical representation

The ·canonical representation· for shortshort is defined by prohibiting certain options from the Lexical representation (§3.4.18.1).  Specifically, the the optional "+" sign is prohibited and leading zeroes are prohibited.

3.4.18.3 Constraining facets Facets

short has the following ·constraining facets·:

short and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

short has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from short may also specify values for the following ·constraining facets·:

short has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = true
  • cardinality = finite
  • numeric = true
3.4.18.4 Derived datatypes

The following ·built-in· datatype is ·derived· from short

3.4.19 byte

[Definition:]   byte is derived from short by setting the value of ·maxInclusive· to be 127 and ·minInclusive· to be -128. The ·base type· of byte is short.

3.4.19.1 Lexical representation

bytebyte has a lexical representation consisting of an optional sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39).  If the sign is omitted, "+" is assumed. For example: -1, 0, 126, +100.

3.4.19.2 Canonical representation

The ·canonical representation· for bytebyte is defined by prohibiting certain options from the Lexical representation (§3.4.19.1).  Specifically, the the optional "+" sign is prohibited and leading zeroes are prohibited.

3.4.19.3 Constraining facets Facets

byte has the following ·constraining facets·:

byte and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

byte has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from byte may also specify values for the following ·constraining facets·:

byte has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = true
  • cardinality = finite
  • numeric = true

3.4.20 nonNegativeInteger

[Definition:]   nonNegativeInteger is derived from integer by setting the value of ·minInclusive· to be 0.  This results in the standard mathematical concept of the non-negative integers. The ·value space· of nonNegativeInteger is the infinite set {0,1,2,...}.  The ·base type· of nonNegativeInteger is integer.

3.4.20.1 Lexical representation

nonNegativeIntegernonNegativeInteger has a lexical representation consisting of an optional sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39).  If the sign is omitted, the positive sign ('+') is assumed. If the sign is present, it must be "+" except for lexical forms denoting zero, which may be preceded by a positive ('+') or a negative ('-') sign. For example: 1, 0, 12678967543233, +100000.

3.4.20.2 Canonical representation

The ·canonical representation· for nonNegativeIntegernonNegativeInteger is defined by prohibiting certain options from the Lexical representation (§3.4.20.1).  Specifically, the the optional "+" sign is prohibited and leading zeroes are prohibited.

3.4.20.3 Constraining facets Facets

nonNegativeInteger has the following ·constraining facets·:

nonNegativeInteger and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

nonNegativeInteger has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from nonNegativeInteger may also specify values for the following ·constraining facets·:

nonNegativeInteger has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = false
  • cardinality = countably infinite
  • numeric = true
3.4.20.4 Derived datatypes

The following ·built-in· datatypes are ·derived· from nonNegativeInteger

3.4.21 unsignedLong

[Definition:]   unsignedLong is derived from nonNegativeInteger by setting the value of ·maxInclusive· to be 18446744073709551615.  The ·base type· of unsignedLong is nonNegativeInteger.

3.4.21.1 Lexical representation

unsignedLongunsignedLong has a lexical representation consisting of an optional sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39).  If the sign is omitted, the positive sign ('+') is assumed.  If the sign is present, it must be '+' except for lexical forms denoting zero, which may be preceded by a positive ('+') or a negative ('-') sign. For example: 0, 12678967543233, 100000.

3.4.21.2 Canonical representation

The ·canonical representation· for unsignedLongunsignedLong is defined by prohibiting certain options from the Lexical representation (§3.4.21.1).  Specifically, leading zeroes are prohibited.

3.4.21.3 Constraining facets Facets

unsignedLong has the following ·constraining facets·:

unsignedLong and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

unsignedLong has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from unsignedLong may also specify values for the following ·constraining facets·:

unsignedLong has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = true
  • cardinality = finite
  • numeric = true
3.4.21.4 Derived datatypes

The following ·built-in· datatype is ·derived· from unsignedLong

3.4.22 unsignedInt

[Definition:]   unsignedInt is derived from unsignedLong by setting the value of ·maxInclusive· to be 4294967295.  The ·base type· of unsignedInt is unsignedLong.

3.4.22.1 Lexical representation

unsignedIntunsignedInt has a lexical representation consisting of an optional sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39).  If the sign is omitted, the positive sign ('+') is assumed.  If the sign is present, it must be '+' except for lexical forms denoting zero, which may be preceded by a positive ('+') or a negative ('-') sign. For example: 0, 1267896754, 100000.

3.4.22.2 Canonical representation

The ·canonical representation· for unsignedIntunsignedInt is defined by prohibiting certain options from the Lexical representation (§3.4.22.1).  Specifically, leading zeroes are prohibited.

3.4.22.3 Constraining facets Facets

unsignedInt has the following ·constraining facets·:

unsignedInt and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

unsignedInt has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from unsignedInt may also specify values for the following ·constraining facets·:

unsignedInt has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = true
  • cardinality = finite
  • numeric = true
3.4.22.4 Derived datatypes

The following ·built-in· datatype is ·derived· from unsignedInt

3.4.23 unsignedShort

[Definition:]   unsignedShort is derived from unsignedInt by setting the value of ·maxInclusive· to be 65535.  The ·base type· of unsignedShort is unsignedInt.

3.4.23.1 Lexical representation

unsignedShortunsignedShort has a lexical representation consisting of an optional sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39). If the sign is omitted, the positive sign ('+') is assumed.  If the sign is present, it must be '+' except for lexical forms denoting zero, which may be preceded by a positive ('+') or a negative ('-') sign.  For example: 0, 12678, 10000.

3.4.23.2 Canonical representation

The ·canonical representation· for unsignedShortunsignedShort is defined by prohibiting certain options from the Lexical representation (§3.4.23.1).  Specifically, the leading zeroes are prohibited.

3.4.23.3 Constraining facets Facets

unsignedShort has the following ·constraining facets·:

unsignedShort and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

unsignedShort has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from unsignedShort may also specify values for the following ·constraining facets·:

unsignedShort has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = true
  • cardinality = finite
  • numeric = true
3.4.23.4 Derived datatypes

The following ·built-in· datatype is ·derived· from unsignedShort

3.4.24 unsignedByte

[Definition:]   unsignedByte is derived from unsignedShort by setting the value of ·maxInclusive· to be 255.  The ·base type· of unsignedByte is unsignedShort.

3.4.24.1 Lexical representation

unsignedByteunsignedByte has a lexical representation consisting of an optional sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39). If the sign is omitted, the positive sign ('+') is assumed.  If the sign is present, it must be '+' except for lexical forms denoting zero, which may be preceded by a positive ('+') or a negative ('-') sign.  For example: 0, 126, 100.

3.4.24.2 Canonical representation

The ·canonical representation· for unsignedByteunsignedByte is defined by prohibiting certain options from the Lexical representation (§3.4.24.1).  Specifically, leading zeroes are prohibited.

3.4.24.3 Constraining facets Facets

unsignedByte has the following ·constraining facets·:

unsignedByte and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

unsignedByte has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from unsignedByte may also specify values for the following ·constraining facets·:

unsignedByte has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = true
  • cardinality = finite
  • numeric = true

3.4.25 positiveInteger

[Definition:]   positiveInteger is derived from nonNegativeInteger by setting the value of ·minInclusive· to be 1.  This results in the standard mathematical concept of the positive integer numbers.  The ·value space· of positiveInteger is the infinite set {1,2,...}.  The ·base type· of positiveInteger is nonNegativeInteger.

3.4.25.1 Lexical representation

positiveIntegerpositiveInteger has a lexical representation consisting of an optional positive sign ('+') followed by a non-empty finite-length sequence of decimal digits (#x30-#x39).  For example: 1, 12678967543233, +100000.

3.4.25.2 Canonical representation

The ·canonical representation· for positiveIntegerpositiveInteger is defined by prohibiting certain options from the Lexical representation (§3.4.25.1).  Specifically, the optional "+" sign is prohibited and leading zeroes are prohibited.

3.4.25.3 Constraining facets Facets

positiveInteger has the following ·constraining facets·:

positiveInteger and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

positiveInteger has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from positiveInteger may also specify values for the following ·constraining facets·:

positiveInteger has the following values for its ·fundamental facets·:

  • ordered = total
  • bounded = false
  • cardinality = countably infinite
  • numeric = true

3.4.26 yearMonthDuration

[Definition:]   yearMonthDuration is a datatype derived from duration by restricting its ·lexical representations· to instances of yearMonthDurationLexicalRep.  The ·value space· of yearMonthDuration is therefore that of duration restricted to those whose ·seconds· property is 0.  This results in a duration datatype which is totally ordered.

Note: The always-zero ·seconds· is formally retained in order that yearMonthDuration's (abstract) value space truly be a subset of that of duration  An obvious implementation optimization is to ignore the zero and implement yearMonthDuration values simply as integer values.
3.4.26.1 The yearMonthDuration Lexical Mapping
The lexical space is reduced from that of duration by disallowing duDayFrag and duTimeFrag fragments in the ·lexical representations·.
The yearMonthDuration Lexical Representation
yearMonthDurationLexicalRep ::= '-'? 'PduYearMonthFrag

The lexical space of yearMonthDuration consists of strings which match the regular expression '-?P((([0-9]+Y)([0-9]+M)?)|([0-9]+M))' or the expression '-?P[0-9]+(Y([0-9]+M)?|M)', but the formal definition of yearMonthDuration uses a simpler regular expression in its ·pattern· facet: '[^DT]*'. This pattern matches only strings of characters which contain no 'D' and no 'T', thus restricting the ·lexical space· of duration to strings with no day, hour, minute, or seconds fields.

The ·canonical mapping· is that of duration restricted in its range to the ·lexical space· (which reduces its domain to omit any values not in the yearMonthDuration value space).

Note: The yearMonthDuration value whose ·months· and ·seconds· are both zero has no ·canonical representation· in this datatype since its ·canonical representation· in duration ('PT0S') is not in the ·lexical space· of yearMonthDuration.
3.4.26.2 Facets

yearMonthDuration has the following ·constraining facets·:

yearMonthDuration and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

yearMonthDuration has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from yearMonthDuration may also specify values for the following ·constraining facets·:

yearMonthDuration has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = false
  • cardinality = countably infinite
  • numeric = false
Note: The ordered facet has the value partial even though the datatype is in fact totally ordered, because (as explained in ordered (§4.2.2)), the value of that facet is unchanged by derivation.

3.4.27 dayTimeDuration

[Definition:]   dayTimeDuration is a datatype derived from duration by restricting its ·lexical representations· to instances of dayTimeDurationLexicalRep. The ·value space· of dayTimeDuration is therefore that of duration restricted to those whose ·months· property is 0.  This results in a duration datatype which is totally ordered.

3.4.27.1 The dayTimeDuration Lexical Space

The lexical space is reduced from that of duration by disallowing duYearFrag and duMonthFrag fragments in the ·lexical representations·.

The dayTimeDuration Lexical Representation
dayTimeDurationLexicalRep ::= '-'? 'PduDayTimeFrag

The lexical space of dayTimeDuration consists of strings in the ·lexical space· of duration which match the regular expression '[^YM]*[DT].*'; this pattern eliminates all durations with year or month fields, leaving only those with day, hour, minutes, and/or seconds fields.

The ·canonical mapping· is that of duration restricted in its range to the ·lexical space· (which reduces its domain to omit any values not in the dayTimeDuration value space).

3.4.27.2 Facets

dayTimeDuration has the following ·constraining facets·:

dayTimeDuration and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

dayTimeDuration has the following ·constraining facets· with the values shown; these facets may be further restricted in the derivation of new types:

Datatypes derived by restriction from dayTimeDuration may also specify values for the following ·constraining facets·:

dayTimeDuration has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = false
  • cardinality = countably infinite
  • numeric = false
Note: The ordered facet has the value partial even though the datatype is in fact totally ordered, because (as explained in ordered (§4.2.2)), the value of that facet is unchanged by derivation.

3.4.28 dateTimeStamp

[Definition:]   The dateTimeStamp datatype is derived from dateTime by giving the value required to its explicitTimezone facet. The result is that all values of dateTimeStamp are required to have explicit time zone offsets and the datatype is totally ordered.

3.4.28.1 The dateTimeStamp Lexical Space

As a consequence of requiring an explicit time zone offset, the lexical space of dateTimeStamp is reduced from that of dateTime by requiring a timezoneFrag fragment in the ·lexical representations·.

The dateTimeStamp Lexical Representation
dateTimeStampLexicalRep ::= yearFrag '-monthFrag '-dayFrag 'T' ((hourFrag ':minuteFrag ':secondFrag) | endOfDayFrag) timezoneFrag   Constraint:  Day-of-month Representations
Note: For details of the Day-of-month Representations (§3.3.8.4) constraint, see dateTime, from which the constraint is inherited.

In other words, the lexical space of dateTimeStamp consists of strings which are in the ·lexical space· of dateTime and which also match the regular expression '.*(Z|(\+|-)[0-9][0-9]:[0-9][0-9])'.

The ·lexical mapping· is that of dateTime restricted to the dateTimeStamp lexical space.

The ·canonical mapping· is that of dateTime restricted to the dateTimeStamp value space.

3.4.28.2 Facets

dateTimeStamp has the following ·constraining facets·:

dateTimeStamp and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:

Datatypes derived by restriction from dateTimeStamp may also specify values for the following ·constraining facets·:

dateTimeStamp has the following values for its ·fundamental facets·:

  • ordered = partial
  • bounded = false
  • cardinality = countably infinite
  • numeric = false
Note: The ordered facet has the value partial even though the datatype is in fact totally ordered, because (as explained in ordered (§4.2.2)), the value of that facet is unchanged by derivation.

4 Datatype components

The preceding sections of this specification have described datatypes in a way largely independent of their use in the particular context of schema-aware processing as defined in [XSD 1.1 Part 1: Structures].

This section presents the mechanisms necessary to integrate datatypes into the context of [XSD 1.1 Part 1: Structures], mostly in terms of the schema component abstraction introduced there. The account of datatypes given in this specification is also intended to be useful in other contexts. Any specification or other formal system intending to use datatypes as defined above, particularly if definition of new datatypes via facet-based restriction is envisaged, will need to provide analogous mechanisms for some, but not necessarily all, of what follows below. For example, the {target namespace} and {final} properties are required because of particular aspects of [XSD 1.1 Part 1: Structures] which are not in principle necessary for the use of datatypes as defined here.

The following sections provide full details on the properties and significance of each kind of schema component involved in datatype definitions. For each property, the kinds of values it is allowed to have is specified.  Any property not identified as optional is required to be present; optional properties which are not present have absent as their value. Any property identified as a having a set, subset or ·list· value may have an empty value unless this is explicitly ruled out: this is not the same as absent. Any property value identified as a superset or a subset of some set may be equal to that set, unless a proper superset or subset is explicitly called for.

For more information on the notion of datatype (schema) components, see Schema Component Details of [XSD 1.1 Part 1: Structures].

[Definition:]  A component may be referred to as the owner of its properties, and of the values of those properties.

next sub-section4.1 Simple Type Definition

Simple Type Definitions provide for:

  • In the case of ·primitive· datatypes, identifying a datatype with its definition in this specification.
  • In the case of ·constructed· datatypes, defining the datatype in terms of other datatypes.
  • Attaching a QName to the datatype.

4.1.1 The Simple Type Definition Schema Component

The Simple Type Definition schema component has the following properties:

Schema Component: Simple Type Definition
{annotations}
A sequence of Annotation components.
{name}
An xs:NCName value. Optional.
{target namespace}
An xs:anyURI value. Optional.
{final }
A subset of {substitution, extension, restriction, list, union}.
{final}

A subset of {restriction, extension, list, union}

{context}
Required if {name} is absent, otherwise must be absent
{base type definition }
A Simple Type Definition component. Required.

If the datatype has been ·derived· by ·restriction· then the Simple Type Definition component from which it is ·derived·, otherwise the Simple Type Definition for anySimpleType (§4.1.6).

{base type definition}
A Type Definition component. Required.
{facets}
A set of Constraining Facet components.
{fundamental facets}
A set of Fundamental Facet components.
{variety }
One of {atomic, list, union}. Required.
{variety}
One of {atomic, list, union}. Required for all Simple Type Definitions except ·anySimpleType·, in which it is absent.
{primitive type definition}
A Simple Type Definition component. With one exception, required if {variety} is atomic, otherwise must be absent. The exception is ·anyAtomicType·, whose {primitive type definition} is absent.

If not absent, must be a ·primitive· built-in definition.

{item type definition}
A Simple Type Definition component. Required if {variety} is list, otherwise must be absent.
{member type definitions}
A sequence of Simple Type Definition components.

Must be present (but may be empty) if {variety} is union, otherwise must be absent.

DatatypesSimple type definitions are identified by their {name} and {target namespace}.  Except for anonymous datatypesSimple Type Definitions (those with no {name}), datatype definitionsSimple Type Definitions ·must·must be uniquely identified within a schema. Within a valid schema, each Simple Type Definition uniquely determines one datatype. The ·value space·, ·lexical space·, ·lexical mapping·, etc., of a Simple Type Definition are the ·value space·, ·lexical space·, etc., of the datatype uniquely determined (or "defined") by that Simple Type Definition.

If {variety} is ·atomic· then the ·value space· of the datatype defined will be a subset of the ·value space· of {base type definition} (which is a subset of the ·value space· of {primitive type definition}). If {variety} is ·list· then the ·value space· of the datatype defined will be the set of (possibly empty) finite-length sequences of values from the ·value space· of {item type definition}. If {variety} is ·union· then the ·value space· of the datatype defined will be a subset (possibly an improper subset) of the union of the ·value spaces· of each datatypeSimple Type Definition in {member type definitions}.

If {variety} is ·atomic· then the {variety} of {base type definition} must be ·atomic·, unless the {base type definition} is anySimpleType. If {variety} is ·list· then the {variety} of {item type definition} must be either ·atomic· or ·union·, and if {item type definition} is ·union· then all its ·basic members· must be ·atomic·. If {variety} is ·union· then {member type definitions} must be a list of datatype definitionsSimple Type Definitions.

The value of {facets} consists of the set of ·facet·s specified directly in the datatype definition unioned with the possibly empty set of {facets} of {base type definition}.

The value of {fundamental facets} consists of the set of ·fundamental facet·s and their values.

The {facets} property determines the ·value space· and ·lexical space· of the datatype being defined by imposing constraints which must be satisfied by values and ·lexical representations·.

The {fundamental facets} property provides some basic information about the datatype being defined: its cardinality, whether an ordering is defined for it by this specification, whether it has upper and lower bounds, and whether it is numeric.

If {final} is the empty set then the type can be used in deriving other types; the explicit values restriction, list and union prevent further derivations of Simple Type Definitions by ·restriction··facet-based restriction·, ·list· and ·union· respectively.; the explicit value extension prevents any derivation of Complex Type Definitions by extension.

The {context} property is only relevant for anonymous type definitions, for which its value is the component in which this type definition appears as the value of a property, e.g. {item type definition} or {base type definition}.

4.1.2 XML Representation of Simple Type Definition Schema Components

The XML representation for a Simple Type Definition schema component is a <simpleType> element information item. The correspondences between the properties of the information item and properties of the component are as follows:

XML Representation Summary: simpleType Element Information Item et al.

<simpleType
  final = (#all | List of (list | union | restriction | extension))
  id = ID
  name = NCName
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, (restriction | list | union))
</simpleType>

<restriction
  base = QName
  id = ID
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | maxScale | minScale | length | minLength | maxLength | enumeration | whiteSpace | pattern | assertion | explicitTimezone | {any with namespace: ##other})*))
</restriction>

<list
  id = ID
  itemType = QName
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, simpleType?)
</list>

<union
  id = ID
  memberTypes = List of QName
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?, simpleType*)
</union>

Simple Type Definition Schema Component
Property
Representation
 
The actual value of the namename [attribute], if present on the <simpleType> element, otherwise nullabsent
 
The actual value of the targetNamespacetargetNamespace [attribute] of the parent schemaschema element information item, if present, otherwise absent.
 
The appropriate case among the following:
1 If the <restriction> alternative is chosen, then the type definition resolved to by the actual value of the base [attribute] of <restriction>, if present, otherwise the type definition corresponding to the <simpleType> among the [children] of <restriction>.
2 If the <list> or <union> alternative is chosen, then ·anySimpleType·.
 
A set corresponding to the actual value of the final [attribute], if present, otherwise the actual value of the finalDefault [attribute] of the ancestor schema element information item, if present, otherwise the empty string, as follows:
the empty string
the empty set;
#all
{restriction, list, union};
otherwise
a set with members drawn from the set above, each being present or absent depending on whether the string contains an equivalently named space-delimited substring.
Note: Although the finalDefault [attribute] of schema may include values other than restriction, list or union, those values are ignored in the determination of {final}
 
A subset of {restriction, extension, list, union}, determined as follows. [Definition:]  Let FS be the actual value of the final [attribute], if present, otherwise the actual value of the finalDefault [attribute] of the ancestor schema element, if present, otherwise the empty string. Then the property value is the appropriate case among the following:
1 If ·FS· is the empty string, then the empty set;
2 If ·FS· is '#all', then {restriction, extension, list, union};
3 otherwise Consider ·FS· as a space-separated list, and include restriction if 'restriction' is in that list, and similarly for extension, list and union.
 
The appropriate case among the following:
1 If the name [attribute] is present, then absent
2 otherwise the appropriate case among the following:
2.1 If the parent element information item is <attribute>, then the corresponding Attribute Declaration
2.2 If the parent element information item is <element>, then the corresponding Element Declaration
2.3 If the parent element information item is <list> or <union>, then the Simple Type Definition corresponding to the grandparent <simpleType> element information item
2.4 otherwise (the parent element information item is <restriction>), the appropriate case among the following:
2.4.1 If the grandparent element information item is <simpleType>, then the Simple Type Definition corresponding to the grandparent
2.4.2 otherwise (the grandparent element information item is <simpleContent>), the Simple Type Definition which is the {content type} of the Complex Type Definition corresponding to the great-grandparent <complexType> element information item.
 
If the <list> alternative is chosen, then list, otherwise if the <union> alternative is chosen, then union, otherwise (the <restriction> alternative is chosen) the {variety} of the {base type definition}.
 
The annotation corresponding to the <annotation> element information item in the [children], if present, otherwise null
 
The appropriate case among the following:
1 If the <restriction> alternative is chosen, then a set of Constraining Facet components constituting a restriction of the {facets} of the {base type definition} with respect to a set of Constraining Facet components corresponding to the appropriate element information items among the [children] of <restriction> (i.e. those which specify facets, if any), as defined in Schema Component Constraint: Simple Type Restriction (Facets) .
2 If the <list> alternative is chosen, then a set with one member, a whiteSpace facet with {value} = collapse and {fixed} = true.
3 otherwise the empty set
 
The annotation mapping of the set of elements containing the <simpleType>, and the <restriction>, the <list>, or the <union> [child], whichever is present, as defined in section XML Representation of Annotation Schema Components of [XSD 1.1 Part 1: Structures].
[Definition:]  The ancestors of a type definition are its {base type definition} and the ·ancestors· of its {base type definition}. (The ancestors of a Simple Type Definition T in the type hierarchy are themselves type definitions; they are distinct from the XML elements which may be ancestors, in the XML document hierarchy, of the <simpleType> element which declares T.)
If the {variety} is atomic, the following additional property mapping also applies:
Property
Representation
 
From among the ·ancestors· of this Simple Type Definition, that Simple Type Definition which corresponds to a ·primitive· datatype.
Example
An electronic commerce schema might define a datatype called 'SKU' (the barcode number that appears on products) from the ·built-in· datatype string by supplying a value for the ·pattern· facet.
<simpleType name='SKU'>
    <restriction base='string'>
      <pattern value='\d{3}-[A-Z]{2}'/>
    </restriction>
</simpleType>
In this case, 'SKU' is the name of the new ·user-defined· datatype, string is its ·base type· and ·pattern· is the facet.
If the {variety} is list, the following additional property mappings also apply:
Property
Representation
 
The appropriate case among the following:
1 If the {base type definition} is ·anySimpleType·, then the Simple Type Definition (a) resolved to by the actual value of the itemType [attribute] of <list>, or (b) corresponding to the <simpleType> among the [children] of <list>, whichever is present.
Note: In this case, a <list> element will invariably be present; it will invariably have either an itemType [attribute] or a <simpleType> [child], but not both.
2 otherwise (that is, the {base type definition} is not ·anySimpleType·), the {item type definition} of the {base type definition}.
Note: In this case, a <restriction> element will invariably be present.
Example
A system might want to store lists of floating point values.
<simpleType name='listOfFloat'>
  <list itemType='float'/>
</simpleType>
In this case, listOfFloat is the name of the new ·user-defined· datatype, float is its ·item type· and ·list· is the derivation method.
If the {variety} is union, the following additional property mappings also apply:
Property
Representation
 
The appropriate case among the following:
1 If the {base type definition} is ·anySimpleType·, then the sequence of (a) the Simple Type Definitions (a) resolved to by the items in the actual value of the memberTypes [attribute] of <union>, if any, and (b) those corresponding to the <simpleType>s among the [children] of <union>, if any, in order.
Note: In this case, a <union> element will invariably be present; it will invariably have either a memberTypes [attribute] or one or more <simpleType> [children], or both.
2 otherwise (that is, the {base type definition} is not ·anySimpleType·), the {member type definitions} of the {base type definition}.
Note: In this case, a <restriction> element will invariably be present.

Editorial Note: Priority Feedback Request

Note that the rule just given allows ·unions· to be members of other ·unions·. This is a change from version 1.0 of this specification, which prohibited ·unions· in {member type definitions} and replaced any reference to a ·union· M, in the XML declaration of a second ·union· U, with the members of M. This had the unintended consequence that that if M had facets they were lost, and U erroneously accepted values not accepted by M. In order to correct this error, this version of this specification allows ·unions· in {member type definitions} and removes the wording which replaced references to ·unions· with their members.

The XML Schema Working Group solicits input from implementors and users of this specification as to whether this change is an acceptable way of repairing the problem in version 1.0 of this specification, or whether it would be preferable to allow ·unions· as members of other ·unions· only if they have an empty {facets} property. If such a change would make this specification more (or less) attractive to users or implementors, please let us know.

Example
As an example, taken from a typical display oriented text markup language, one might want to express font sizes as an integer between 8 and 72, or with one of the tokens "small", "medium" or "large".  The ·union· Simple Type Definition below would accomplish that.
<xsd:attribute name="size">
  <xsd:simpleType>
    <xsd:union>
      <xsd:simpleType>
        <xsd:restriction base="xsd:positiveInteger">
          <xsd:minInclusive value="8"/>
          <xsd:maxInclusive value="72"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType>
        <xsd:restriction base="xsd:NMTOKEN">
          <xsd:enumeration value="small"/>
          <xsd:enumeration value="medium"/>
          <xsd:enumeration value="large"/>
        </xsd:restriction>
      </xsd:simpleType>
    </xsd:union>
  </xsd:simpleType>
</xsd:attribute>
<p>
<font size='large'>A header</font>
</p>
<p>
<font size='12'>this is a test</font>
</p>

A ·derived· datatype can be ·derived··constructed· from a ·primitive· datatype or another derivedan ·ordinary· datatype by one of three means: by restriction·facet-based restriction·, by list·list· or by union·union·.

4.1.2.1 Derivation by restriction
XML Representation Summary: del-restriction Element Information Item

Simple Type Definition Schema Component
Property
Representation
 
 
The union of the set of Facets (§2.5) components resolved to by the facet [children] merged with {facets} from {base type definition}, subject to the Facet Restriction Valid constraints specified in Facets (§2.5).
 
The Simple Type Definition component resolved to by the actual value of the base [attribute] or the <simpleType> [children], whichever is present.
Example
An electronic commerce schema might define a datatype called Sku (the barcode number that appears on products) from the ·built-in· datatype string by supplying a value for the ·pattern· facet.
<simpleType name='Sku'>
    <restriction base='string'>
      <pattern value='\d{3}-[A-Z]{2}'/>
    </restriction>
</simpleType>
In this case, Sku is the name of the new ·user-derived· datatype, string is its ·base type· and ·pattern· is the facet.
4.1.2.2 Derivation by list
XML Representation Summary: old-list Element Information Item

Simple Type Definition Schema Component
Property
Representation
 
list
 
The Simple Type Definition component resolved to by the actual value of the itemType [attribute] or the <simpleType> [children], whichever is present.

A ·list· datatype must be ·derived· from an ·atomic· or a ·union· datatype, known as the ·item type· of the ·list· datatype. This yields a datatype whose ·value space· is composed of finite-length sequences of values from the ·value space· of the ·item type· and whose ·lexical space· is composed of space-separated lists of ·literals· of the ·item type·.

Example
A system might want to store lists of floating point values.
<simpleType name='listOfFloat'>
  <list itemType='float'/>
</simpleType>
In this case, listOfFloat is the name of the new ·user-derived· datatype, float is its ·item type· and ·list· is the derivation method.

As mentioned in List Datatypes (§2.6.1.2), when a datatype is derived from a ·list· datatype, the following ·constraining facets· can be used:

regardless of the ·constraining facets· that are applicable to the ·atomic· datatype that serves as the ·item type· of the ·list·.

For each of ·length·, ·maxLength· and ·minLength·, the unit of length is measured in number of list items. The value of ·whiteSpace· is fixed to the value collapse.

4.1.2.3 Derivation by union
XML Representation Summary: old-union Element Information Item

Simple Type Definition Schema Component
Property
Representation
 
union
 
The sequence of Simple Type Definition components resolved to by the items in the actual value of the memberTypes [attribute], if any, in order, followed by the Simple Type Definition components resolved to by the <simpleType> [children], if any, in order. If {variety} is union for any Simple Type Definition components resolved to above, then the Simple Type Definition is replaced by its {member type definitions}.

A ·union· datatype can be ·derived· from one or more ·atomic·, ·list· or other ·union· datatypes, known as the ·member types· of that ·union· datatype.

Example
As an example, taken from a typical display oriented text markup language, one might want to express font sizes as an integer between 8 and 72, or with one of the tokens "small", "medium" or "large".  The ·union· type definitionSimple Type Definition below would accomplish that.
<xsd:attribute name="size">
  <xsd:simpleType>
    <xsd:union>
      <xsd:simpleType>
        <xsd:restriction base="xsd:positiveInteger">
          <xsd:minInclusive value="8"/>
          <xsd:maxInclusive value="72"/>
        </xsd:restriction>
      </xsd:simpleType>
      <xsd:simpleType>
        <xsd:restriction base="xsd:NMTOKEN">
          <xsd:enumeration value="small"/>
          <xsd:enumeration value="medium"/>
          <xsd:enumeration value="large"/>
        </xsd:restriction>
      </xsd:simpleType>
    </xsd:union>
  </xsd:simpleType>
</xsd:attribute>
<p>
<font size='large'>A header</font>
</p>
<p>
<font size='12'>this is a test</font>
</p>
As mentioned in Union datatypes (§2.6.1.3), when a datatype is derived from a ·union· datatype, the only following ·constraining facets· can be used:

regardless of the ·constraining facets· that are applicable to the datatypes that participate in the ·union·

4.1.3 Constraints on XML Representation of Simple Type Definition

Schema Representation Constraint: Single Facet Value
Unless otherwise specifically allowed by this specification (Multiple patterns (§4.3.4.3) and Multiple enumerations (§4.3.5.3)) any given ·constraining facet· can only be specifed once within a single derivation step.
Schema Representation Constraint: itemType attribute or simpleType child
Either the itemType [attribute] or the <simpleType> [child] of the <list> element must be present, but not both.
Schema Representation Constraint: base attribute or simpleType child
Either the base [attribute] or the simpleType [child] of the <restriction> element must be present, but not both.
Schema Representation Constraint: memberTypes attribute or simpleType children
Either the memberTypes [attribute] of the <union> element must be non-empty or there must be at least one simpleType [child].

4.1.4 Simple Type Definition Validation Rules

Validation Rule: Facet Valid
A value in a ·value space· is facet-valid with respect to a ·constraining facet· component if and only if:
1 the value is facet-valid with respect to the particular ·constraining facet· as specified below.
Validation Rule: Datatype Valid
A string is datatype-valid with respect to a datatype definition if:
1 it ·matches· a ·literal· in the ·lexical space· of the datatype, determined as follows:
1.1 if ·pattern· is a member of {facets}, then the string must be pattern valid (§4.3.4.4);
1.2 if ·pattern· is not a member of {facets}, then
1.2.2 if {variety} is ·list· then the string must be a sequence of space-separated tokens, each of which ·match·es a ·literal· in the ·lexical space· of {item type definition}
1.2.3 if {variety} is ·union· then the string must ·match· a ·literal· in the ·lexical space· of at least one member of {member type definitions}
2 the value denoted by the ·literal· ·matched· in the previous step is a member of the ·value space· of the datatype, as determined by it being Facet Valid (§4.1.4) with respect to each member of {facets} (except for ·pattern·).
A ·literal· is datatype-valid with respect to a Simple Type Definition if and only if it is a member of the ·lexical space· of the corresponding datatype.
Note: Since every value in the ·value space· is denoted by some ·literal·, and every ·literal· in the ·lexical space· maps to some value, the requirement that the ·literal· be in the ·lexical space· entails the requirement that the value it maps to should fulfill all of the constraints imposed by the {facets} of the datatype. If the datatype is a ·list·, the Datatype Valid constraint also entails that each whitespace-delimited token in the list be datatype-valid against the ·item type· of the list. If the datatype is a ·union·, the Datatype Valid constraint entails that the ·literal· be datatype-valid against at least one of the ·member types·.
That is, the constraints on Simple Type Definitions and on datatype derivation defined in this specification have as a consequence that a ·literal· L is datatype-valid with respect to a Simple Type Definition T if and only if either T corresponds to a ·special· datatype or all of the following are true:
1 If there is a pattern in {facets}, then L is pattern valid (§4.3.4.4) with respect to the pattern. If there are other ·lexical· facets in {facets}, then L is facet-valid with respect to them.
2 The appropriate case among the following is true:
2.1 If the {variety} of T is ·atomic·, then L is in the ·lexical space· of the {primitive type definition} of T, as defined in the appropriate documentation. Let V be the member of the ·value space· of the {primitive type definition} of T mapped to by L, as defined in the appropriate documentation.
Note: For ·built-in· ·primitives·, the "appropriate documentation" is the relevant section of this specification. For ·implementation-defined· ·primitives·, it is the normative specification of the ·primitive·, which will typically be included in, or referred to from, the implementation's documentation.
2.2 If the {variety} of T is ·list·, then each space-delimited substring of L is Datatype Valid with respect to the {item type definition} of T. Let V be the sequence consisting of the values identified by Datatype Valid for each of those substrings, in order.
2.3 If the {variety} of T is ·union·, then L is Datatype Valid with respect to at least one member of the {member type definitions} of T. Let B be the ·active basic member· of T for L. Let V be the value identified by Datatype Valid for L with respect to B.
3 V, as determined by the appropriate sub-clause of clause 2 above, is Facet Valid (§4.1.4) with respect to each member of the {facets} of T which is a ·value-based· (and not a ·pre-lexical· or ·lexical·) facet.
Note that whiteSpace facets and other ·pre-lexical· facets do not take part in checking Datatype Valid. In cases where this specification is used in conjunction with schema-validation of XML documents, such facets are used to normalize infoset values before the normalized results are checked for datatype validity. In the case of unions the ·pre-lexical· facets to use are those associated with B in clause 2.3 above. When more than one ·pre-lexical· facet applies, the whiteSpace facet is applied first; the order in which ·implementation-defined· facets are applied is ·implementation-defined·.

4.1.5 Constraints on Simple Type Definition Schema Components

Schema Component Constraint: Applicable Facets
The ·constraining facets· which are allowed to be members of {facets} are dependent on {base type definition} as specified in the following tabledepend on the {variety} and {primitive type definition} of the type, as follows:
{base type definition}applicable {facets}
If {variety} is list, then
[all datatypes]length, minLength, maxLength, pattern, enumeration, whiteSpace
If {variety} is union, then
[all datatypes]pattern, enumeration
else if {variety} is atomic, then
stringlength, minLength, maxLength, pattern, enumeration, whiteSpace, assertions
booleanpattern, whiteSpace, assertions
floatpattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions
doublepattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions
decimaltotalDigits, fractionDigits, pattern, whiteSpace, enumeration, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions
precisionDecimaltotalDigits, maxScale, minScale, pattern, whiteSpace, enumeration, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions
durationpattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions
dateTimepattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
timepattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
datepattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
gYearMonthpattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
gYearpattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
gMonthDaypattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
gDaypattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
gMonthpattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
hexBinarylength, minLength, maxLength, pattern, enumeration, whiteSpace, assertions
base64Binarylength, minLength, maxLength, pattern, enumeration, whiteSpace, assertions
anyURIlength, minLength, maxLength, pattern, enumeration, whiteSpace, assertions
QNamelength, minLength, maxLength, pattern, enumeration, whiteSpace, assertions
NOTATIONlength, minLength, maxLength, pattern, enumeration, whiteSpace, assertions

If {variety} is absent, then no facets are applicable. (This is true for anySimpleType.)

If {variety} is list, then the applicable facets are assertions, length, minLength, maxLength, pattern, enumeration, and whiteSpace.

If {variety} is union, then the applicable facets are pattern and enumeration. pattern, enumeration, and assertions.

If {variety} is atomic, and {primitive type definition} is absent then no facets are applicable. (This is true for anyAtomicType.)

In all other cases ({variety} is atomic and {primitive type definition} is not absent), then the applicable facets are shown in the table below.

{primitive type definition}applicable {facets}
stringlength, minLength, maxLength, pattern, enumeration, whiteSpace, assertions
booleanpattern, whiteSpace, assertions
floatpattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions
doublepattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions
decimaltotalDigits, fractionDigits, pattern, whiteSpace, enumeration, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions
precisionDecimaltotalDigits, maxScale, minScale, pattern, whiteSpace, enumeration, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions
durationpattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions
dateTimepattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
timepattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
datepattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
gYearMonthpattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
gYearpattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
gMonthDaypattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
gDaypattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
gMonthpattern, enumeration, whiteSpace, maxInclusive, maxExclusive, minInclusive, minExclusive, assertions, explicitTimezone
hexBinarylength, minLength, maxLength, pattern, enumeration, whiteSpace, assertions
base64Binarylength, minLength, maxLength, pattern, enumeration, whiteSpace, assertions
anyURIlength, minLength, maxLength, pattern, enumeration, whiteSpace, assertions
QNamelength, minLength, maxLength, pattern, enumeration, whiteSpace, assertions
NOTATIONlength, minLength, maxLength, pattern, enumeration, whiteSpace, assertions
Note: For any ·implementation-defined· primitive types, it is ·implementation-defined· which constraining facets are applicable to them.
Similarly, for any ·implementation-defined· constraining facets, it is ·implementation-defined· which ·primitives· they apply to.
Schema Component Constraint: list of atomic
Schema Component Constraint: no circular unions

4.1.6 Simple Type Definition for anySimpleType

There is a simple type definition nearly equivalent to the simple version of the ur-type definition present in every schema by definition.  It has the following properties:

4.1.7 Built-in Simple Type Definitions

The Simple Type Definition of anySimpleType is present in every schema.  It has the following properties:

Property
Value
'anySimpleType'
'http://www.w3.org/2001/XMLSchema'
The empty set
absent
The empty set
absent
The empty sequence

The definition of anySimpleType is the root of the Simple Type Definition hierarchy; as such it mediates between the other simple type definitions, which all eventually trace back to it via their {base type definition} properties, and the definition of anyType, which is its {base type definition}.

The Simple Type Definition of anyAtomicType is present in every schema.  It has the following properties:

Property
Value
'anyAtomicType'
'http://www.w3.org/2001/XMLSchema'
The empty set
absent
The empty set
atomic
The empty sequence

Simple type definitions for all the built-in primitive datatypes, namely string, boolean, float, double, decimal, precisionDecimal, dateTime, duration, time, date, gMonth, gMonthDay, gDay, gYear, gYearMonth, hexBinary, base64Binary, anyURI are present by definition in every schema.  All have a very similar structure, with only the {name}, the {primitive type definition} (which is self-referential), the {fundamental facets}, and in one case the {facets} varying from one to the next:

Property
Value
[as appropriate]
'http://www.w3.org/2001/XMLSchema'
The empty set
atomic
{a whiteSpace facet with {value} = collapse and {fixed} = true in all cases except string, which has {value} = preserve and {fixed} = false}
[as appropriate]
absent
The empty sequence
·Implementation-defined· ·primitives· must have a Simple Type Definition with the values shown above, with the following exceptions.
  1. The {facets} property must contain a whiteSpace facet, the value of which is ·implementation-defined·. It may contain other facets, whether defined in this specification or ·implementation-defined·.
  2. The value of {annotations} may be empty, but need not be.
Note: It is a consequence of the rule just given that each ·implementation-defined· ·primitive· will have an expanded name by which it can be referred to.
Note: ·Implementation-defined· datatypes will normally have a value other than 'http://www.w3.org/2001/XMLSchema' for the {target namespace} property. That namespace is controlled by the W3C and datatypes will be added to it only by W3C or its designees.

Similarly, Simple Type Definitions for all the built-in ·ordinary· datatypes are present by definition in every schema, with properties as specified in Derived datatypesOther Built-in Datatypes (§3.4) and as represented in XML in Illustrative XML representations for the built-in ordinary type definitions (§C.2).

Property
Value
[as appropriate]
'http://www.w3.org/2001/XMLSchema'
The empty set
[atomic or list, as specified in the appropriate sub-section of Derived datatypesOther Built-in Datatypes (§3.4)]
[as specified in the appropriate sub-section of Derived datatypesOther Built-in Datatypes (§3.4)]
absent
if {variety} is atomic, then absent, otherwise as specified in the appropriate sub-section of Derived datatypesOther Built-in Datatypes (§3.4)]
As shown in the XML representations of the ordinary built-in datatypes in Illustrative XML representations for the built-in ordinary type definitions (§C.2)

previous sub-section next sub-section4.2 Fundamental Facets

        4.2.1 equal
        4.2.2 ordered
            4.2.2.1 The ordered Schema Component
        4.2.3 bounded
            4.2.3.1 The bounded Schema Component
        4.2.4 cardinality
            4.2.4.1 The cardinality Schema Component
        4.2.5 numeric
            4.2.5.1 The numeric Schema Component

[Definition:]   Each fundamental facet is a schema component that provides a limited piece of information about some aspect of each datatype.  All ·fundamental facet· components are defined in this section.  For example, cardinality is a ·fundamental facet·.  Most ·fundamental facets· are given a value fixed with each primitive datatype's definition, and this value is not changed by subsequent ·derivations· (even when it would perhaps be reasonable to expect an application to give a more accurate value based on the constraining facets used to define the ·derivation·).  The cardinality and bounded facets are exceptions to this rule; their values may change as a result of certain ·derivations·.

Note: Schema components are identified by kind.  "Fundamental" is not a kind of component.  Each kind of ·fundamental facet· ("ordered", "bounded", etc.) is a separate kind of schema component.

A ·fundamental facet· can occur only in the {fundamental facets} of a Simple Type Definition, and this is the only place where ·fundamental facet· components occur.    Each kind of ·fundamental facet· component occurs (once) in each Simple Type Definition's {fundamental facets} set.

Note: The value of any ·fundamental facet· component can always be calculated from other properties of its ·owner·.  Fundamental facets are not required for schema processing, but some applications use them.

4.2.1 equal

Every ·value space· supports the notion of equality, with the following rules:

On every datatype, the operation Equal is defined in terms of the equality property of the ·value space·: for any values a, b drawn from the ·value space·, Equal(a,b) is true if a = b, and false otherwise.

Note that in consequence of the above:

Note: There is no schema component corresponding to the equal ·fundamental facet·.

4.2.2 ordered

[Definition:]  An order relation on a ·value space· is a mathematical relation that imposes a ·total order· or a ·partial order· on the members of the ·value space·.

[Definition:]  A ·value space·, and hence a datatype, is said to be ordered if there exists an ·order-relation· defined for that ·value space·.

[Definition:]   A partial order is an ·order-relation· that is irreflexive, asymmetric and transitive.

A ·partial order· has the following properties:

The notation a <> b is used to indicate the case when a != b and neither a < b nor b < a. For any values a and b from different ·primitive· ·value spaces·, a <> b.

[Definition:]  When a <> b, a and b are incomparable,[Definition:]  otherwise they are comparable.

[Definition:]   A total order is an ·partial order· such that for no a and b is it the case that a <> b.

A ·total order· has all of the properties specified above for ·partial order·, plus the following property:

Note: The fact that this specification does not define an ·order-relation· for some datatype does not mean that some other application cannot treat that datatype as being ordered by imposing its own order relation.

·ordered· provides for:

For some datatypes, this document specifies an order relation for their value spaces (see Order (§2.2.3)); the ordered facet reflects this. It takes the values total, partial, and false, with the meanings described below. For the ·primitive· datatypes, the value of the ordered facet is specified in Fundamental Facets (§F.1). For ·ordinary· datatypes, the value is inherited without change from the ·base type·. For a ·list·, the value is always false; for a ·union·, the value is computed as described below.

A false value means no order is prescribed; a total value assures that the prescribed order is a total order; a partial value means that the prescribed order is a partial order, but not (for the primitive type in question) a total order.

Note: The value false in the ordered facet does not mean no partial or total ordering exists for the value space, only that none is specified by this document for use in checking upper and lower bounds. Mathematically, any set of values possesses least one trivial partial ordering, in which every value pair that is not equal is incomparable.
Note: When new datatypes are derived from datatypes with partial orders, the constraints imposed can sometimes result in a value space for which the ordering is total, or trivial. The value of the ordered facet is not, however, changed to reflect this. The value partial should therefore be interpreted with appropriate caution.

[Definition:]  A ·value space·, and hence a datatype, is said to be ordered if some members of the ·value space· are drawn from a ·primitive· datatype for which the table in Fundamental Facets (§F.1) specifies the value total or partial for the ordered facet.

Note: Some of the "real-world" datatypes which are the basis for those defined herein are ordered in some applications, even though no order is prescribed for schema-processing purposes.  For example, boolean is sometimes ordered, and string and ·list· datatypes ·constructed· from ordered ·atomic· datatypes are sometimes given "lexical" orderings.  They are not ordered for schema-processing purposes.
4.2.2.1 The ordered Schema Component
Schema Component: ordered, a kind of Fundamental Facet
{value}
One of {false, partial, total}. Required.

{value} depends on {variety}, {facets} and {member type definitions} in the Simple Type Definition component in which a ·ordered· component appears as a member of {fundamental facets}.

When {variety} is ·atomic·, {value} is inherited from {value} of {base type definition}. For all ·primitive· types {value} is as specified in the table in Fundamental Facets (§F.1).

When {variety} is ·list·, {value} is false.

When {variety} is ·union·, {value} is partial unless one of the following:

{value} depends on the ·owner's· {variety}, {facets}, and {member type definitions}. The appropriate case among the following must be true:
1 If the ·owner's· {variety} is atomic, then the appropriate case among the following must be true:
1.1 If the ·owner· is ·primitive·, then {value} is as specified in the table in Fundamental Facets (§F.1).
2 If the ·owner's· {variety} is list, then {value} is false.
3 otherwise the ·owner's· {variety} is union; the appropriate case among the following must be true:
3.1 If every ·basic member· of the ·owner· has {variety} atomic and has the same {primitive type definition}, then {value} is the same as the ordered component's {value} in that primitive type definition's {fundamental facets}.
3.2 If each member of the ·owner's· {member type definitions} has an ordered component in its {fundamental facets} whose {value} is false, then {value} is false.
3.3 otherwise {value} is partial.

4.2.3 bounded

[Definition:]   A value u in an ·ordered·  ·value space· U is said to be an inclusive upper bound of a ·value space· V (where V is a subset of U) if for all v in V, u >= v.

[Definition:]   A value u in an ·ordered·  ·value space· U is said to be an exclusive upper bound of a ·value space· V (where V is a subset of U) if for all v in V, u > v.

[Definition:]   A value l in an ·ordered·  ·value space· L is said to be an inclusive lower bound of a ·value space· V (where V is a subset of L) if for all v in V, l <= v.

[Definition:]   A value l in an ·ordered·  ·value space· L is said to be an exclusive lower bound of a ·value space· V (where V is a subset of L) if for all v in V, l < v.

·bounded· provides for:

Some ordered datatypes have the property that there is one value greater than or equal to every other value, and another that is less than or equal to every other value.  (In the case of ·ordinary· datatypes, these two values are not necessarily in the value space of the derived datatype, but they must be in the value space of the primitive datatype from which they have been derived.) The bounded facet value is boolean and is generally true for such bounded datatypes.  However, it will remain false when the mechanism for imposing such a bound is difficult to detect, as, for example, when the boundedness occurs because of derivation using a pattern component.

4.2.3.1 The bounded Schema Component
Schema Component: bounded, a kind of Fundamental Facet
{value}
An xs:boolean value. Required.

{value} depends on the ·owner's· {variety}, {facets} and {member type definitions} in the Simple Type Definition component in which a bounded component appears as a member of {fundamental facets}.

When the ·owner· is ·primitive·, {value} is as specified in the table in Fundamental Facets (§F.1).  Otherwise, when the ·owner's· {variety} is atomic, if one of minInclusive or minExclusive and one of maxInclusive or maxExclusive are among {facets}members of the ·owner's· {facets} set, then {value} is true; elseotherwise {value} is false.

When the ·owner's· {variety} is list, if ·length· or both of ·minLength· and ·maxLength· are among {facets}, then {value} is true; else {value} is false.

When the ·owner's· {variety} is union, if {value} is true for every member of {member type definitions}and all members of {member type definitions}the ·owner's· {member type definitions} set and share a common ancestorall of the ·owner's· ·basic members· have the same {primitive type definition}, then {value} is true; elseotherwise {value} is false.

4.2.4 cardinality

[Definition:]  Every ·value space· has associated with it the concept of cardinality.  Some ·value spaces· are finite, some are countably infinite while still others could conceivably be uncountably infinite (although no ·value space· defined by this specification is uncountable infinite). A datatype is said to have the cardinality of its ·value space·.

It is sometimes useful to categorize ·value spaces· (and hence, datatypes) as to their cardinality.  There are two significant cases:

·cardinality· provides for:

Every value space has a specific number of members.  This number can be characterized as finite or infinite.  (Currently there are no datatypes with infinite value spaces larger than countable.)  The cardinality facet value is either finite or countably infinite and is generally finite for datatypes with finite value spaces.  However, it will remain countably infinite when the mechanism for causing finiteness is difficult to detect, as, for example, when finiteness occurs because of a derivation using a pattern component.

4.2.4.1 The cardinality Schema Component
Schema Component: cardinality, a kind of Fundamental Facet
{value}
One of {finite, countably infinite}. Required.

{value} depends on the ·owner's· {variety}, {facets}, and {member type definitions} in the Simple Type Definition component in which a cardinality component appears as a member of {fundamental facets}.

When {variety} is ·atomic· and {value} of {base type definition} is finite, then {value} is finite.

When {variety} is ·atomic· and {value} of {base type definition} is countably infinite and either of the following conditions are true, then {value} is finite; else {value} is countably infinite:

  1. all of the following are true:
    1. either of the following are true:
      1. {base type definition} is one of date, gYearMonth, gYear, gMonthDay, gDay or gMonth or any type derived from them
When the ·owner· is ·primitive·, {value} is as specified in the table in Fundamental Facets (§F.1).  Otherwise, when the ·owner's· {variety} is atomic, {value} is countably infinite unless any of the following conditions are true, in which case {value} is finite:
  1. at least one of length, maxLength, or totalDigits is a member of the ·owner's· {facets} set,
  2. all of the following are true:
    1. one of minInclusive or minExclusive is a member of the ·owner's· {facets} set
    2. one of maxInclusive or maxExclusive is a member of the ·owner's· {facets} set
    3. either of the following are true:
      1. fractionDigits is a member of the ·owner's· {facets} set

When the ·owner's· {variety} is list, if length or both of minLength and maxLength are among {facets}members of the ·owner's· {facets} set and the ·owner's· {item type definition}'s cardinality {value} is finite then {value} is finite; elseotherwise {value} is countably infinite.

When the ·parent'sowner's· {variety} is union, if cardinality's {value} is finite for every member of the ·owner's· {member type definitions} set then {value} is finite, elseotherwise {value} is countably infinite.

4.2.5 numeric

[Definition:]  A datatype is said to be numeric if its values are conceptually quantities (in some mathematical number system).

[Definition:]  A datatype whose values are not ·numeric· is said to be non-numeric.

·numeric· provides for:

Some value spaces are made up of things that are conceptually numeric, others are not. The numeric facet value indicates which are considered numeric.

4.2.5.1 The numeric Schema Component
Schema Component: numeric, a kind of Fundamental Facet
{value}
An xs:boolean value. Required.

{value} depends on the ·owner's· {variety}, {facets}, {base type definition} and {member type definitions} in the Simple Type Definition component in which a ·cardinality· component appears as a member of {fundamental facets}.

When the ·owner· is ·primitive·, {value} is as specified in the table in Fundamental Facets (§F.1).  Otherwise, when the ·owner's· {variety} is atomic, {value} is inherited from the ·owner's· {base type definition}'s numeric{value} of {base type definition}. For all ·primitive· types {value} is as specified in the table in Fundamental Facets (§F.1).

When the ·owner's· {variety} is list, {value} is false.

When the ·owner's· {variety} is union, if numeric's {value} is true for every member of the ·owner's· {member type definitions} set then {value} is true, elseotherwise {value} is false.

previous sub-section 4.3 Constraining Facets

        4.3.1 length
            4.3.1.1 The length Schema Component
            4.3.1.2 XML Representation of length Schema Components
            4.3.1.3 length Validation Rules
            4.3.1.4 Constraints on length Schema Components
        4.3.2 minLength
            4.3.2.1 The minLength Schema Component
            4.3.2.2 XML Representation of minLength Schema Component
            4.3.2.3 minLength Validation Rules
            4.3.2.4 Constraints on minLength Schema Components
        4.3.3 maxLength
            4.3.3.1 The maxLength Schema Component
            4.3.3.2 XML Representation of maxLength Schema Components
            4.3.3.3 maxLength Validation Rules
            4.3.3.4 Constraints on maxLength Schema Components
        4.3.4 pattern
            4.3.4.1 The pattern Schema Component
            4.3.4.2 XML Representation of pattern Schema Components
            4.3.4.3 Constraints on XML Representation of pattern
            4.3.4.4 pattern Validation Rules
            4.3.4.5 Constraints on pattern Schema Components
        4.3.5 enumeration
            4.3.5.1 The enumeration Schema Component
            4.3.5.2 XML Representation of enumeration Schema Components
            4.3.5.3 Constraints on XML Representation of enumeration
            4.3.5.4 enumeration Validation Rules
            4.3.5.5 Constraints on enumeration Schema Components
        4.3.6 whiteSpace
            4.3.6.1 The whiteSpace Schema Component
            4.3.6.2 XML Representation of whiteSpace Schema Components
            4.3.6.3 whiteSpace Validation Rules
            4.3.6.4 Constraints on whiteSpace Schema Components
        4.3.7 maxInclusive
            4.3.7.1 The maxInclusive Schema Component
            4.3.7.2 XML Representation of maxInclusive Schema Components
            4.3.7.3 maxInclusive Validation Rules
            4.3.7.4 Constraints on maxInclusive Schema Components
        4.3.8 maxExclusive
            4.3.8.1 The maxExclusive Schema Component
            4.3.8.2 XML