<?xml version='1.0'?>
<!-- Id: datatypes.xml,v 1.7.2.48 2004/07/15 08:25:54 ht Exp  -->
<?xml-stylesheet type='text/xsl' href='xmlschema_nodiffs.xsl'?>
<!DOCTYPE spec SYSTEM "local.dtd" [
<!ENTITY suffix "">
]>
<spec w3c-doctype="wd" status="ext-review">
<header>
<title>XML Schema 1.1 Part 2: Datatypes</title>
    <w3c-designation>wd-20040716</w3c-designation>
   <w3c-doctype>W3C Working Draft</w3c-doctype>
    <pubdate>
      <day>16</day>
      <month>July</month>
      <year>2004</year><!--  Id: datatypes.xml,v 1.7.2.48 2004/07/15 08:25:54 ht Exp  -->
    </pubdate>
<publoc> <loc href="http://www.w3.org/TR/2004/WD-xmlschema11-2-20040716/">http://www.w3.org/TR/2004/WD-xmlschema11-2-20040716/</loc> </publoc>
   <altlocs>
    <loc href="http://www.w3.org/TR/2004/WD-xmlschema11-2-20040716/datatypes.xml">XML</loc>
    <loc href="http://www.w3.org/TR/2004/WD-xmlschema11-2-20040716/datatypes-with-errata.html">XHTML with visible change markup</loc>
    <loc href="http://www.w3.org/2001/XMLSchema.xsd">Independent copy of the schema for schema documents</loc>
    <loc href="http://www.w3.org/2001/XMLSchema-datatypes.xsd">A schema for built-in datatypes only, in a separate namespace</loc>
    <loc href="http://www.w3.org/2001/XMLSchema.dtd">Independent copy of the DTD for schema documents</loc>
   </altlocs>
   <latestloc><loc diff="del" href="http://www.w3.org/TR/xmlschema-2/">http://www.w3.org/TR/xmlschema-2/</loc><loc diff="add" href="http://www.w3.org/TR/xmlschema11-2/">http://www.w3.org/TR/xmlschema11-2/</loc></latestloc>
<prevlocs>
<!--* 
	<loc href="http://www.w3.org/TR/2004/PER-xmlschema-2-20040318/">
		http://www.w3.org/TR/2004/PER-xmlschema-2-20040318/
	</loc>
*-->
</prevlocs>
<authlist>
<author>
<name>David Peterson</name>
<affiliation>invited expert (SGML<emph>Works!</emph>)</affiliation>
<email href="mailto:davep@iit.edu">davep@iit.edu</email>
</author>
<author>
<name>Paul V. Biron</name>
<affiliation>Kaiser Permanente, for Health Level Seven</affiliation>
<email href="mailto:Paul.V.Biron@kp.org">Paul.V.Biron@kp.org</email>
</author>
<author>
<name>Ashok Malhotra</name>
<affiliation>invited expert (formerly of Microsoft)</affiliation>
<email href="mailto:ashokmalhotra@alum.mit.edu">ashokmalhotra@alum.mit.edu</email>
</author>
</authlist>
<status>
    <p><emph>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 <loc href="http://www.w3.org/TR/">W3C technical reports index</loc> at http://www.w3.org/TR/.</emph></p>
 <p diff="chg">This is the <xspecref
href="http://www.w3.org/2004/02/Process-20040205/tr.html#first-wd">First
Public Working Draft</xspecref> of XML Schema 1.1.  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.  It attempts to be
complete in indicating <emph>what</emph> will change from version 1.0,
but is <emph>not</emph> complete in terms of fully specifying
<emph>how</emph> things will change.</p>
 <p diff="add">For those primarily interested in the changes since version 1.0,
the <specref ref="changes"/> 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.</p>
 <p>Please send comments on this Working Draft to <loc href="mailto:www-xml-schema-comments@w3.org">www-xml-schema-comments@w3.org</loc> (<loc href="http://lists.w3.org/Archives/Public/www-xml-schema-comments/">archive</loc>).</p>
<p>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.</p>

    <p>
    This document has been produced by the <loc href="http://www.w3.org/XML/Schema">W3C XML Schema Working Group</loc> as
    part of the W3C <loc href="http://www.w3.org/XML/Activity">XML Activity</loc>. The
    goals of the XML Schema language version 1.1 are discussed in the <loc href="http://www.w3.org/TR/2003/WD-xmlschema-11-req-20030121/">Requirements for XML Schema 1.1</loc> document. The authors of this document are the
    members of the XML Schema Working Group.  Different parts of this
    specification have different editors.
    </p>
 <p diff="chg">Patent disclosures relevant to this specification may be found
on the Working Group's <loc role="disclosure"
href="http://www.w3.org/2004/01/pp-impl/19482/status">Patent
disclosure page</loc> in conformance with the <loc
href="http://www.w3.org/Consortium/Patent-Policy-20040205/">W3C Patent
Policy</loc> of 5 February 2004.  An individual who has actual
knowledge of a patent which the individual believes contains Essential
Claim(s) with respect to this specification should disclose the
information in accordance with <loc
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the W3C Patent Policy</loc>.</p>
      
      <p diff="add">Per <loc
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Exclusion">section
4 of the W3C Patent Policy</loc>, Working Group participants have 150
days from the title page date of this document to exclude essential
claims from the W3C RF licensing requirements with respect to this
document series. Exclusions are with respect to the exclusion
reference document, defined by the <loc
href="http://www.w3.org/Consortium/Patent-Policy-20040205/">W3C Patent
Policy</loc> to be the latest
version of a document in this series that is published no later than
90 days after the title page date of this document.</p>
    <p>The English version of this specification is the only normative
    version. Information about translations of this document is available
    at <loc href="http://www.w3.org/2001/05/xmlschema-translations">http://www.w3.org/2001/05/xmlschema-translations</loc>.</p>
</status>
<abstract>
<p>
<emph>XML Schema: Datatypes</emph> 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<phrase diff="del"> 1.0</phrase>, provides a superset of the capabilities found in XML<phrase diff="del"> 1.0</phrase>
document type definitions (DTDs) for specifying datatypes on elements
and attributes.
<issue id="RQ-152i" role="1.1">
  <p><loc href="&reqs;#xml1.1" target="reqs">RQ-152 (xml1.1)</loc></p>
  <p>How should this specification be aligned with XML 1.1?  The changes in
character set and name characters, and the question of what determines which
ones to use, must be addressed.</p>
 </issue></p>
</abstract>
<langusage>
<language id="EN">English</language>
      <language id="ebnf">Extended Backus-Naur Form (formal grammar)</language>
</langusage>
<revisiondesc>
<slist><sitem/></slist>
</revisiondesc>
</header>
<body>


<div1 role="1.0" id="Intro">
<head>Introduction</head>

<issue id="RQ-21i" role="1.1">
<p><loc href="&reqs;#bnf" target="reqs">RQ-21 (regex/BNF for all primitive types)</loc></p>
<p>Current plan is that all datatypes defined herein will have EBNF productions at least approximately defining their lexical space,
and will include a nonnormative regex derived from the EBNF if a user wishes to copy it directly.</p>
</issue>

<issue id="RQ-24-2i" role="1.1">
<p><loc href="&reqs;#fundamentals" target="reqs">RQ-24 (systematic facets: canonical representations for all datatypes)</loc></p>
<p>It is not possible for all datatypes to have canonical representations of all values without violating the rules of derivation
or adding special-purpose &cfacet;s which the WG does not deem appropriate.&nbsp; The WG has not yet decided how to deal with
datatypes whose lexical and/or canonical mappings are context sensitive.</p>
</issue>

<issue id="RQ-148i" role="1.1">
<p><loc href="&reqs;#Truncation-not-defined" target="reqs">RQ-148 (clarify use of "truncation)</loc></p>
<p>The word will probably be removed.</p>
</issue>

<issue id="RQ-120i" role="1.1">
<p><loc href="&reqs;#term-derived" target="reqs">RQ-120 (consistent use of "derived)</loc></p>
<p>"Derivations" other than "derivations by restriction" will be renamed "constructions".</p>
</issue>



<issue id="RQ-24-4i" role="1.1">
<p><loc href="&reqs;#fundamentals" target="reqs">RQ-24 (systematic facets: assignment of datatype to nodes without components)</loc></p>
</issue>
    <div2 id="intro1.1" diff="add">
   <head>Introduction to Version 1.1</head>
     <p>The Working Group has two main goals for this version of W3C XML Schema:</p>
     <ulist>
<item><p>Significant improvements in simplicity of design and clarity of
   exposition <emph>without</emph> loss of backward <emph>or</emph> forward compatibility;

 </p></item>
<item><p>Provision of support for versioning of XML languages defined using
   the XML Schema specification, including the XML transfer syntax for
   schemas itself.</p></item>
</ulist>
<p>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:</p>
<olist>
<item><p>Add support for versioning (acknowledging that this <emph>may</emph>
    be slightly disruptive to the XML transfer syntax at the margins)</p></item>
<item><p>Allow bug fixes (unless in specific cases we decide that the fix
    is too disruptive for a point release)</p></item>
<item><p>Allow editorial changes</p></item>
<item><p>Allow design cleanup to change behavior in edge cases</p></item>
<item><p>Allow relatively non-disruptive changes to type hierarchy (to
    better support current and forthcoming international standards and
W3C recommendations)</p></item>
<item><p>Allow design cleanup to change component structure (changes
    to functionality restricted to edge cases)</p></item>
<item><p>Do not allow any significant changes in functionality</p></item>
<item><p>Do not allow any changes to XML transfer syntax except those
    required by version control hooks and bug fixes</p></item>
</olist>
<p>The overall aim as regards compatibility is that</p>

<ulist>
<item><p>All schema documents conformant to version 1.0 of this
    specification should also conform to version 1.1, and should have
    the same validation behaviour across 1.0 and 1.1 implementations
    (except possibly in edge cases and in the details of the resulting
    PSVI);</p></item>
<item><p>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 behaviour across 1.0 and 1.1 implementations
    (again except possibly in edge cases and in the details of the
    resulting PSVI);
 </p></item>
</ulist>
    </div2>
      <div2 role="1.0" id="purpose">
<head>Purpose</head>
<p>
The <bibref ref="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
<emph>documents</emph> and those transporting <emph>data</emph> in XML,
often require a higher degree of type checking to ensure robustness in
document understanding and data interchange.
</p>
<p>
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.
</p>
<table class="dtdemo" border="1">
<thead>
<tr>
<th>Data oriented</th>
<th>Document oriented</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<eg><![CDATA[<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>]]></eg>
</td>
<td>
<eg><![CDATA[<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>]]></eg>
</td>
</tr>
</tbody>
</table>
<p>
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).&nbsp; 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").&nbsp; 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.
</p>
<p>
In both cases, validity constraints exist on the content of the
instances that are not expressible in XML DTDs.&nbsp; The limited datatyping
facilities in XML have prevented validating XML processors from supplying
the rigorous type checking required in these situations.&nbsp; The result
has been that individual applications writers have had to implement type
checking in an ad hoc manner.&nbsp; 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.&nbsp; As discussed below, these datatypes could be used in other
XML-related standards as well.
</p>
</div2>
<div2 role="1.0" id="requirements">
<head>Requirements</head>
<p>
The <bibref ref="schema-requirements"/> document spells out
concrete requirements to be fulfilled by this specification,
which state that the XML Schema Language must:
</p>
<olist>
<item>
<p>
provide for primitive data typing, including byte, date,
integer, sequence, SQL and Java primitive datatypes, etc.;
</p>
</item>
<item>
<p>
define a type system that is adequate for import/export
from database systems (e.g., relational, object, OLAP);
</p>
</item>
<item>
<p>
distinguish requirements relating to lexical data representation
vs. those governing an underlying information set;
</p>
</item>
<item>
<p>
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).
</p>
</item>
</olist>
</div2>
<div2 role="1.0" id="scope">
<head>Scope</head>
<p>
This portion of the XML Schema Language discusses datatypes that can be
used in an XML Schema.&nbsp; These datatypes can be specified for element
content that would be specified as
<xspecref href="&xmlspec;#dt-chardata">#PCDATA</xspecref> and attribute
values of <xspecref href="&xmlspec;#sec-attribute-types">various
types </xspecref> in a DTD.&nbsp; 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 <bibref ref="XSL"/> and
<bibref ref="RDFSchema"/>.
</p>
</div2>
<div2 role="1.0" id="terminology">
<head>Terminology</head>
<p>
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:
</p>
<glist>
<gitem>
<label>
<termdef id="dt-compatibility" term="for compatibility">
for compatibility</termdef>
</label>
<def>
<p>
A feature of this specification included solely to ensure that schemas
which use this feature remain compatible with <bibref ref="XML"/>
</p>
</def>
</gitem>
<gitem>
<label>
<termdef id="dt-may" term="may"><term>may</term></termdef>
</label>
<def>
<p>
Conforming documents and processors are permitted to but need
not behave as described.
</p>
</def>
</gitem>
<gitem>
<label>
<termdef id="dt-match" term="match"><term>match</term></termdef>
</label>
<def>
<p>
(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 it belongs to the
language generated by that production.
</p>
</def>
</gitem>
<gitem>
<label>
 <termdef id="dt-must" term="must"><term>must</term></termdef>
</label>
<def>
<p>
Conforming documents and processors are required to behave as
described; otherwise they are in <termref def="dt-error">error</termref>.
</p>
</def>
</gitem>
<gitem>
<label>
<termdef id="dt-error" term="error"><term>error</term></termdef>
</label>
<def>
<p>
A violation of the rules of this specification; results are undefined.
Conforming software <termref def="dt-may"/> detect and report an
<term>error</term> and <termref def="dt-may"/> recover from it.
</p>
</def>
</gitem>
</glist>
</div2>

<div2 role="1.0" id="constraints-and-contributions">
<head>Constraints and Contributions</head>
<p>
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:
</p>
<glist>
<gitem>
<label>
<termdef id="dt-cos" term="Constraint on Schemas">
<term>Constraint on Schemas</term>
</termdef>
</label>
<def>
<p>
Constraints on the schema components themselves, i.e. conditions
components <termref def="dt-must"/> satisfy to be components at all.
Largely to be found in <specref ref="datatype-components"/>.
</p>
</def>
</gitem>
<gitem>
<label>
<termdef id="dt-src" term="Schema Representation Constraint">
<term>Schema Representation Constraint</term>
</termdef>
</label>
<def>
<p>
Constraints on the representation of schema components in XML.&nbsp; Some but
not all of these are expressed in <specref ref="schema"/> and
<specref ref="dtd-for-datatypeDefs"/>.
</p>
</def>
</gitem>
<gitem>
<label>
<termdef id="dt-cvc" term="Validation Rule">
<term>Validation Rule</term>
</termdef>
</label>
<def>
<p>
Constraints expressed by schema components which information
items <termref def="dt-must"/> satisfy to be schema-valid.&nbsp; Largely
to be found in <specref ref="datatype-components"/>.
</p>
</def>
</gitem>
</glist>
</div2>
</div1>

 <!-- ****************************** BEGIN NEW 1.1 MATERIAL (DATATYPES/FACETS) ********************************* -->

<div1 id="typesystem">
<head diff="add">Datatype System</head>

<!--ednote><edtext>I don't want to use the word <mention>type</mention> without some prefix or adjective.</edtext></ednote-->

<p>This section describes the conceptual framework behind the <phrase diff="add">data</phrase>type system
defined in this specification.&nbsp; The framework has been influenced by the
<bibref ref="ISO11404"/> standard on language-independent datatypes as
well as the datatypes for <bibref ref="SQL"/> and for programming
languages such as Java.</p>

<!--ednote><edtext>Our datatypes are <emph>not</emph> <unusual>computer representations</unusual>.&nbsp; Our value spaces are the
abstract concepts; appropriate computer representations are determined by the implementers.</edtext></ednote-->

<p>The datatypes discussed in this specification are <phrase diff="del">computer
representations of</phrase><phrase diff="add">for the most part</phrase> well known abstract concepts such as
<emph>integer</emph> and <emph>date</emph>. It is not the place of this
specification to <phrase diff="add">thoroughly </phrase>define these abstract concepts; many other publications
provide excellent definitions.<phrase diff="add">  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.</phrase></p>

<note diff="add">
<p>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.&nbsp; For example, the description herein of the <dtref ref="float"/> datatype
does not define addition or multiplication, much less all of the operations defined for
that datatype in <bibref ref="ieee754"/> on which it is based.</p>
</note>

<div2 id="datatype">
<head>Datatype</head>
<p diff="del">
<termdef id="dt-datatype-delled" term="datatype">In this specification,
a <term>datatype</term> is a 3-tuple, consisting of
a) a set of distinct values, called its <termref def="dt-value-space"/>,
b) a set of lexical representations, called its
<termref def="dt-lexical-space"/>, and c) a set of <termref def="dt-facet"/>s
that characterize properties of the <termref def="dt-value-space"/>,
individual values or lexical items.
</termdef>
</p>



<p diff="add"><termdef term="datatype" id="dt-datatype">In this specification, 
a <term>datatype</term> is a thing with four properties</termdef>:

<ulist><item>
<p>A <termref def="dt-value-space"></termref>, which is 
simply a set.  What the members of this set are called (beyond being generically called <quote>values</quote>)
is influenced by the set of value-space operations and relations used therewith.</p>
</item>




<item>
<p>A <termref def="dt-lexical-space"></termref>, which is the domain of the
<termref def="dt-lexical-mapping"></termref>.&nbsp; <phrase role="UNSURE">Some
<termref def="dt-lexical-mapping">lexical mappings</termref> are context sensitive,
so that the <termref def="dt-lexical-space"></termref> depends on the context in which the
lexical representation occurs.</phrase></p>
</item>

<item>
<p>A small collection of <emph>functions, relations, and procedures</emph> associated with the datatype.&nbsp; Included are equality and order relations on the <termref def="dt-value-space"></termref>, and a <termref def="dt-lexical-mapping"></termref>, which is a function on the <termref def="dt-lexical-space"></termref> onto the <termref def="dt-value-space"></termref>.</p>



<note>
<p>This specification only defines the operations and relations needed for schema processing.&nbsp; 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&mdash;i.e., how to recognize the <quote>real world</quote>
datatypes and their variants for which the datatypes defined herein are
meant to be used for data interchange.</p>
</note>
</item><item>
<p>A <compref ref="dc-defn"/>, which serves to define and/or identify the datatype.</p>
</item>


</ulist>Along with the <termref def="dt-lexical-mapping"></termref> it is often useful
to have an inverse which provides a standard <termref def="dt-lexical-representation"></termref> for
each value.&nbsp; Such a <termref def="dt-canonical-mapping"></termref> 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.</p>
</div2>

<div2 id="value-space"><head>Value space</head>

<p diff="del"><termdef id="dt-value-space-delled" term="value space">A <term>value
space</term> is the set of values for a given datatype.
Each value in the <term>value space</term> of a datatype is denoted by
one or more literals in its <termref def="dt-lexical-space"/>.
</termdef></p>

<p diff="add"><termdef term="value space" id="dt-value-space">The <term>value space</term> <emph>of 
a datatype</emph> is the set of values for that datatype.</termdef>&nbsp; Associated
with each value space are selected operations and 
relations necessary to permit proper schema processing.&nbsp; Each value in the value space 
of a datatype is denoted by one or more character strings in its 
<termref def="dt-lexical-space"></termref>, according 
to <termref role="the" def="dt-lexical-mapping">the lexical mapping</termref>.&nbsp; (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.)</p>

<p diff="add">The value spaces of datatypes are abstractions, and are defined 
in <specref ref="built-in-datatypes"/> to the 
extent needed to clarify them for readers.&nbsp; For example, in defining the numerical datatypes, we assume 
some general numerical concepts such as number and integer are known.&nbsp; In many cases we provide 
references to other documents providing more complete definitions.</p>

<note diff="add">
<p><emph>The value spaces and the values therein are abstractions.</emph>&nbsp; This specification does not 
prescribe any particular internal representations that must be used when implementing these datatypes.&nbsp; 
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.</p>

<p>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&apos; value spaces), and are permitted where
appropriate to even redefine the operations and relations defined within this
specification, provided that <emph>for schema processing the relations and operations
used are those defined herein</emph>.</p>
</note>

<!--ednote><edtext>Could we do away with the following paragraph?&nbsp; Does it really add anything?</edtext></ednote-->

<p>The <termref def="dt-value-space"/> of a <phrase diff="del">given </phrase>datatype can
be defined in one of the following ways:
<ulist>
<item><p>defined<phrase diff="add"> elsewhere</phrase> axiomatically from fundamental notions
(intensional definition)
[see <termref def="dt-primitive"/>]</p>
</item>
<item><p>enumerated outright<phrase diff="add"> from values of an already defined
datatype</phrase> (extensional definition)
[see <termref def="dt-enumeration"/>]</p>
</item>
<item><p>defined by restricting the <termref def="dt-value-space"/> of
an already defined datatype to a particular subset with a given set
of properties [see <termref def="dt-derived"/>]</p>
</item>
<item><p>defined as a combination of values from one or more already defined
<termref def="dt-value-space"/>(s) by a specific construction procedure
[see <termref def="dt-list"/> and <termref def="dt-union"/>]</p>
</item></ulist></p>

<p diff="del">
<termref def="dt-value-space"/>s have certain properties.&nbsp; For example,
they always have the property of <termref def="dt-cardinality"/>,
some definition of <emph>equality</emph>
and might be <termref def="dt-ordered"/>, by which individual
values within the <termref def="dt-value-space"/> can be compared to
one another.&nbsp; The properties of <termref def="dt-value-space"/>s that
are recognized by this specification are defined in
<specref ref="fundamental-facets-delled"/>.
</p>

<p diff="add">The relations of <emph>identity</emph>, <emph>equality</emph>, and <emph>order</emph> are 
required for each value space.&nbsp; A very few datatypes have other relations or operations prescribed for the purposes of this 
specification.</p>

<div3 diff="add" id="identity">
<head> Identity</head>

<p>The identity relation is always defined. Every value space inherently has an 
identity relation. Two things are 
<emph>identical</emph> if they are actually the same thing: i.e., if there is no way whatever to 
tell them apart.&nbsp; The identity relation is used when making restrictions by <emph>enumeration</emph>, and when checking <phrase role="UNSURE">identity constraints</phrase>.&nbsp; These are the only uses of <emph>identity</emph> for schema processing.</p>

<note>
<p>This does not preclude implementing datatypes by using more than one 
<emph>internal</emph> representation for a given value, provided no mechanism inherent in 
the datatype implementation (i.e., other than bit-string-preserving &quot;casting&quot; of 
the datum to a different datatype) will distinguish between the two representations.</p>
</note>

<p>In the identity relation defined herein, values
from different <termref def="dt-primitive"/> datatypes&apos; <termref def="dt-value-space">value
spaces</termref> are made artificially distinct if they
might otherwise be considered identical.&nbsp; For example, there is a
number <emph>two</emph> in the <dtref ref="decimal"/>
datatype and a number <emph>two</emph> in the <dtref ref="float"/>
datatype.&nbsp; In the identity relation defined herein, these
two values are considered distinct.&nbsp; Other applications
making use of these datatypes may choose to consider values such as these identical, but for the
view of <termref def="dt-primitive"/> datatypes&apos; <termref def="dt-value-space">value
spaces</termref> used herein, they are distinct.</p>

<p><emph>WARNING:</emph>&nbsp; Care must be taken when identifying values across distinct primitive
datatypes.&nbsp; It turns out that, for example, 0.1 and 0.10000000009 are effectively identical in
<dtref ref="float"/> but not in <dtref ref="decimal"/>.&nbsp; (Neither 0.1 nor 0.10000000009 are in
the <dtref ref="float"/> value space, but <termref role="the" def="dt-lexical-mapping">the lexical mapping</termref>
of <dtref ref="float"/> maps both <string>0.1</string> and <string>0.10000000009</string> to
the same number (0.100000001490116119384765625) that <emph>is</emph> in the <dtref ref="float"/> value space.)</p>

</div3>

<div3 diff="add" id="equality"><head>Equality</head>

<p>Each <termref def="dt-primitive"></termref> datatype has prescribed an equality relation for its value 
space.&nbsp; The equality relation for most datatypes is the identity relation.&nbsp; In the few cases
where it is not, it has been carefully defined so as to be a <emph>congruence relation</emph> for most
other operations of interest to the datatype.&nbsp; (This means simply that 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.&nbsp; 
For example, identity is <emph>by definition</emph> a congruence relation for all other operations
of interest.)&nbsp; Equality is always a congruence for the order relation.</p><p>On the other hand,
equality need not cover the entire value space of the 
datatype (though it usually does).</p><p>The equality relation is used in conjunction with
order when making restrictions involving order.&nbsp; This is the only use of
<emph>equality</emph> for schema processing.</p>

<note>
<p>In the prior version of
this specification (1.0), equality was always identity.&nbsp; This has been changed
to permit the datatypes defined herein to more closely match the <unusual>real
world</unusual> datatypes for which  they are intended to be used as transmission formats.</p>

<p>For example, the <dtref ref="float"/> datatype has an equality which is not the 
identity (&nbsp;&minus;0&nbsp;=&nbsp;+0&nbsp;, but they are not identical&mdash;although
they <emph>were</emph> identical in the 1.0 version of this specification), and whose
domain excludes one value, NaN, so that&nbsp; NaN&nbsp;&ne;&nbsp;NaN&nbsp;.</p>

<p>For another example, the <dtref ref="dateTime"/> datatype previously lost any timezone
information in the <termref def="dt-lexical-representation"></termref> as the value was
converted to timezone Z; now the timezone is retained and two values representing the
same <unusual>moment in time</unusual> but with different remembered timezones are now
<emph>equal</emph> but not <emph>identical</emph>.</p>
</note>

<p>In the equality relation defined herein, values
from different primitive data spaces are made artificially unequal even if they might
otherwise be considered equal.&nbsp; For example, there is a number <emph>two</emph> in
the <dtref ref="decimal"/>
datatype and a number <emph>two</emph> in the <dtref ref="float"/> datatype.&nbsp; In the equality
relation defined herein, these two values are considered unequal.&nbsp; Other
applications making use of these datatypes
may choose to consider values such as these equal (and must do so if they choose to consider
them identical); nonetheless, in the equality relation defined herein, they are unequal.</p>

<p>For the purposes of this specification, there is one equality relation for all values
of all datatypes (the union of the various datatype&apos;s individual equalities, if one
consider relations to be sets of ordered pairs).&nbsp; The <emph>equality</emph> relation is denoted 
by <mention>=</mention> and its negation by <mention>&ne;</mention>, each used as an binary
infix predicate:&nbsp; <var>x</var>&nbsp;=&nbsp;<var>y</var>&nbsp;
and&nbsp; <var>x</var>&nbsp;&ne;&nbsp;<var>y</var>&nbsp;.&nbsp; On 
the other hand, <emph>identity</emph> relationships are always described in words.</p>

</div3>

<div3 diff="add" id="order"><head>Order</head>

<p>Each datatype has an order relation prescribed.  This order may be a <emph>partial</emph>
order, which means that there may be values in the <termref def="dt-value-space"></termref>
which are neither equal, less-than, nor greater-than.&nbsp; Such value pairs are
<emph>incomparable</emph>.&nbsp; In many cases, the prescribed order is the <unusual>null
order</unusual>:&nbsp; the ultimate partial order, in which no pairs are less-than or
greater-than; they are all equal or incomparable.&nbsp; The order relation is used in
conjunction with equality when making restrictions involving order.&nbsp; This is the
only use of <emph>order</emph> for schema processing.</p>

<p>In this specification, this less-than order relation is denoted by 
<mention>&lt;</mention> (and its inverse by <mention>&gt;</mention>), the weak order by <mention>&le;</mention> 
(and its inverse by <mention>&ge;</mention>), and the resulting 
<emph>incomparable</emph> relation by <mention>&lt;&gt;</mention>, each used as an binary infix predicate:&nbsp;  
<var>x</var>&nbsp;&lt;&nbsp;<var>y</var>&nbsp;,&nbsp; <var>x</var>&nbsp;&le;&nbsp;<var>y</var>&nbsp;,&nbsp; 
<var>x</var>&nbsp;&gt;&nbsp;<var>y</var>&nbsp;,&nbsp; <var>x</var>&nbsp;&ge;&nbsp;<var>y</var>&nbsp;, 
and&nbsp; <var>x</var>&nbsp;&inc;&nbsp;<var>y</var>&nbsp;.</p>

<note>
<p>The weak order <unusual>less-than-or-equal</unusual> means <unusual>less-than</unusual> or
<unusual>equal</unusual>
<emph>and one can tell which</emph>.&nbsp; For example, the <dtref ref="duration"/> P1M
(one month) is <emph>not</emph> less-than-or-equal P31D (thirty-one
days) because P1M is not less than P31D, nor is P1M equal to P31D.&nbsp; Instead,
P1M is incomparable with P31D.)&nbsp; The formal definition of order for <dtref ref="duration"/>
(<specref ref="duration"/>) insures that this is true.</p>
</note>

<p>The value spaces of primitive datatypes are abstractions, which may have values in common.&nbsp; In
the order relation defined herein, these value spaces are made artificially incomparable.&nbsp; For example,
the numbers two and three are values in both the decimal datatype and the float datatype.&nbsp; In the
order relation defined herein, two in the decimal datatype and three in the float datatype are
incomparable values.&nbsp; Other applications making use of these datatypes may choose to consider 
values such as these comparable.</p>

<p>While it is not an error to attempt to compare values from the
value spaces of two different primitive datatypes, they will alway be incomparable and therefore
unequal:&nbsp; If <var>x</var> and <var>y</var> are in the value spaces of different primitive
datatypes then&nbsp; <var>x</var>&nbsp;&inc;&nbsp;<var>y</var>&nbsp; (and
hence&nbsp; <var>x</var>&nbsp;&ne;&nbsp;<var>y</var>&nbsp;).</p>

</div3>
</div2>

<div2 diff="del"><head>Lexical space</head>

<p>In addition to its <termref def="dt-value-space"></termref>, each datatype also
has a lexical space.
</p>
<p><termdef term="lexical space" id="dt-lexical-space-delled">A
<term>lexical space</term> is the set of valid <emph>literals</emph>
for a datatype.
</termdef></p>
<p>
For example, "100" and "1.0E2" are two different literals from the
<termref def="dt-lexical-space"/> of <dtref ref="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.
</p>
<note>
<p>
The literals in the <termref def="dt-lexical-space"/>s defined in this specification
have the following characteristics:
</p>
<glist>
<gitem>
<label>
Interoperability:
</label>
<def>
<p>
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.
</p>
</def>
</gitem>
<gitem>
<label>
Basic readability:
</label>
<def>
<p>
Textual, rather than binary, literals are used.
This makes hand editing, debugging, and similar activities possible.
</p>
</def>
</gitem>
<gitem>
<label>
Ease of parsing and serializing:
</label>
<def>
<p>
Where possible, literals correspond to those found in common
programming languages and libraries.
</p>
</def>
</gitem>
</glist>
</note><div3 id="canonical-lexical-representation-delled">
<head>Canonical Lexical Representation</head>
<p>
While the datatypes defined in this specification have, for the most part,
a single lexical representation i.e. each value in the datatype's
<termref def="dt-value-space"/> is denoted by a single literal in its
<termref def="dt-lexical-space"/>, this is not always the case.&nbsp; The
example in the previous section showed two literals for the datatype
<dtref ref="float"/> which denote the same value.&nbsp; Similarly, there
<termref def="dt-may"/> be
several literals for one of the date or time datatypes that denote the
same value using different timezone indicators.
</p>
<p>
<termdef term="canonical lexical representation" id="dt-canonical-representation-delled">A
<term>canonical lexical representation</term>
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 <term>canonical lexical representation</term> and
values in the <termref def="dt-value-space"/>.
</termdef>
</p>
</div3></div2>

<div2 id="lexical-space" diff="add"><head>The Lexical Space and Lexical Mapping</head>

<!--
<p><termdef term="lexical mapping" id="dt-lexical-mapping">A 
<term>lexical mapping</term> for a datatype is a function whose domain is a set of character 
strings and whose range is a subset of the set of values of that datatype.</termdef>  Lexical 
mappings are designated <emph>active</emph> or <emph>inactive</emph>.&nbsp; Two lexical mappings 
active at the same time must have disjoint domains, or at least must agree on the intersection of their domains; this assures that 
<termref role="the" def="dt-lexical-mapping">the (combined) lexical mapping</termref> is a 
function:  it does not map one lexical representation to more than one value.</p>

<p><termdef term="lexical representation" id="dt-lexical-representation">The 
members of the domain of a lexical mapping are <term>lexical representations</term> (under 
that mapping) of the values to which they are mapped.</termdef></p>

<p><termdef term="the lexical mapping" id="dt-the-lexical-mapping"><term><emph>The</emph> 
lexical mapping</term> of a datatype is the union of all active lexical mappings 
for that datatype.</termdef>&nbsp;  The union of the active lexical mappings will necessarily have as 
its range the <termref def="dt-value-space"></termref>.&nbsp; This
assures that each value has at least 
one <termref def="dt-lexical-representation"></termref>.</p>

<p><termdef term="lexical space" id="dt-lexical-space">The
<term>lexical space</term> of a datatype is the  domain of <termref role="the" def="dt-lexical-mapping">the lexical mapping</termref> 
for that datatype.</termdef>&nbsp;  A datatype may have more than
one<termref def="dt-lexical-mapping"></termref>, and more than 
one may be active, subject to the constraints given above.</p>

<p>Should a datatype have <termref def="dt-lexical-mapping">lexical mappings</termref> whose domains overlap 
and which do not give the same value for character strings in the overlap, then there must be a 
fixed algorithm (possibly dependent on facet values) which selects which lexical mappings are active 
(subject to the constraints above); otherwise there <emph>may</emph> be such an algorithm and 
facet(s).&nbsp; In the absence of such an algorithm all of the datatype's mappings are active.</p>
-->

<ednote><edtext>Some things in this section and elsewhere will need to be rewritten once we decide just how
to deal with context-dependent lexical mappings and lexical spaces.</edtext></ednote>

<p><termdef term="lexical mapping" id="dt-lexical-mapping">The
<term>lexical mapping</term> for a datatype is a prescribed function whose domain is a prescribed set of character 
strings (the <termref def="dt-lexical-space"></termref>) and whose range is the
<termref def="dt-value-space"></termref> of that datatype.</termdef></p>

<p><termdef term="lexical space" id="dt-lexical-space">The
<term>lexical space</term> of a datatype is the prescribed domain of 
<termref role="the" def="dt-lexical-mapping">the lexical mapping</termref> 
for that datatype.</termdef><!-- &nbsp;  A datatype may have more than
one<termref def="dt-lexical-mapping"></termref>, and more than 
one may be active, subject to the constraints given above. --></p>

<p><termdef term="lexical representation" id="dt-lexical-representation">The 
members of the <termref def="dt-lexical-space"></termref> are <term>lexical 
representations</term> of the values to which they are mapped.</termdef></p>

<p>Should a derivation be made using a derivation mechanism that 
removes <termref def="dt-lexical-representation">lexical representations</termref> from
the<termref def="dt-lexical-space"></termref> to the extent that one or more values cease 
to have any <termref def="dt-lexical-representation"></termref>, then those values are
dropped from the <termref def="dt-value-space"></termref>.</p>

<note>
<p>This could happen by means of a <compref ref="dc-pattern"/> facet<!-- or a
<phrase role="UNSURE"><compref ref="NOTATION-facets"/></phrase> facet-->.</p>
</note>

<p>Conversely, should a derivation remove values then their 
<termref def="dt-lexical-representation">lexical representations</termref> are dropped
from the <termref def="dt-lexical-space"></termref> unless there is a facet value whose 
impact is defined to cause the otherwise-dropped <termref def="dt-lexical-representation"></termref>
to be mapped to another value instead.</p>

<note>
<p>There are currently no facets with such an impact.&nbsp; There may be 
in the future.</p>
</note>

<p>For example, &apos;100&apos; and &apos;1.0E2&apos; are two different 
<termref def="dt-lexical-representation">lexical 
representations</termref> from the <dtref ref="float"/> datatype 
which both denote the same value.&nbsp; The datatype 
system defined in this specification provides mechanisms for schema designers
to control the <termref def="dt-value-space"></termref> and the corresponding set of acceptable 
<termref def="dt-lexical-representation">lexical 
representations</termref> of those values for a datatype.</p>

<div3 id="canonical-lexical-representation"><head>Canonical Mapping</head>

<issue id="RQ-129i" role="1.1">
<p><loc href="&reqs;#eliminate-canonical" target="reqs">RQ-129 (remove dependency on canonical representations)</loc></p>
<p>The dependencies are in Part 1; they will be resolved there.&nbsp; Text in this Part will reflect that canonical representation
are provided for the benefit of other users, including other specifications that might want to reference these datatypes.</p>
</issue>

<issue id="RQ-126i" role="1.1">
<p><loc href="&reqs;#restrict-can-forms" target="reqs">RQ-126 (restricting away canonical representations)</loc></p>
<p>Given the "pattern" &cfacet;, restricting away canonical representations cannot be prohibited without undue processing
expense.&nbsp; A warning will be inserted, and RQ-129 will insure that loss of canonical representations will not affect schema processing.</p>
</issue>

<p>While the datatypes defined in this specification generally have
a single <termref def="dt-lexical-representation"></termref> for each value (i.e., each value in the datatype's
<termref def="dt-value-space"></termref> is denoted by a single
<termref def="dt-lexical-representation">representation</termref> in its
<termref def="dt-lexical-space"></termref>), this is not always the case.&nbsp; The
example in the previous section shows two <termref def="dt-lexical-representation">lexical
representations</termref> from the <dtref ref="float"/>
datatype which denote the same value.</p>

<p><termdef id="dt-canonical-mapping" term="canonical mapping">The 
<term>canonical mapping</term> is a prescribed subset of the inverse of a
<termref def="dt-lexical-mapping"></termref> which is 
one-to-one and whose domain (where possible) is the entire range of the
<termref def="dt-lexical-mapping"></termref> (the
<termref def="dt-value-space"></termref>).</termdef>&nbsp; Thus a 
<termref def="dt-canonical-mapping"></termref> selects one
<termref def="dt-lexical-representation"></termref> for each
value in the <termref def="dt-value-space"></termref>.<!-- &nbsp; <phrase role="UNSURE">Most lexical mappings have
an associated canonical mapping; the 
exceptions are a few lexical mappings that are context dependent.</phrase>&nbsp; If
two <termref def="dt-canonical-mapping">canonical mappings</termref> 
with intersecting domains, for a given <termref def="dt-lexical-mapping"></termref>, are
associated with a datatype, then 
there will be a fixed algorithm (possibly dependent on facet values) associated with the 
datatype which resolves any ambiguity of <termref def="dt-canonical-mapping"></termref> in the intersection. --></p>

<p><termdef term="canonical representation" id="dt-canonical-representation">The 
<term>canonical representation</term> of a value in the
<termref def="dt-value-space"></termref> of a datatype is the 
<termref def="dt-lexical-representation"></termref> associated with that value
by the datatype&apos;s <termref def="dt-canonical-mapping"></termref></termdef>.</p>

<!-- <p><termdef id="dt-the-canonical-mapping" term="the canonical mapping"><term><emph>The</emph> 
canonical mapping</term> of a datatype is essentially the union of the
<termref def="dt-canonical-mapping">canonical mappings</termref> 
associated with the active <termref def="dt-lexical-mapping">lexical mappings</termref>,
with values (if any) in the pairwise intersection 
of the domains of those mappings selected according to a fixed algorithm (possibly
having facet values as parameters) associated with the datatype.</termdef></p>
 -->
<p><termref role="the" def="dt-canonical-mapping">Canonical mappings</termref> are not
available for datatypes whose <termref def="dt-lexical-mapping">lexical 
mappings</termref> are context dependent (i.e., mappings for which the value
of a <termref def="dt-lexical-representation"></termref> 
depends on the context in which it occurs, or for which a character string 
may or may not be a valid <termref def="dt-lexical-representation"></termref>
similarly depending on its context)</p><note><p><termref def="dt-canonical-representation">Canonical 
representations</termref> are provided where feasible for the use of other appilications; they are not 
required for schema processing itself.&nbsp; <emph>A conforming schema processor implementation is 
not required to implement <termref def="dt-canonical-mapping">canonical mappings</termref>.</emph></p></note>

</div3>
</div2>

<div2 id="facets">
<head>Facets</head>

<issue id="RQ-24-1i" role="1.1">
<p><loc href="&reqs;#fundamentals" target="reqs">RQ-24 (systematic approach to facets)</loc></p>
<p>This decision is not yet written up herein:&nbsp; The four informational facets, each of which have only one property,
will be lumped into one facet having four properties.&nbsp; This will represent a further technical change to the
facet structure, but will not result in any additional or lost information in a schema.</p>
</issue>

<p diff="del">
<termdef id="dt-facet-delled" term="facet">A <term>facet</term> is a single
defining aspect of a <termref def="dt-value-space"/>.&nbsp; Generally
speaking, each facet characterizes a <termref def="dt-value-space"/>
along independent axes or dimensions.</termdef>
</p>
<p diff="del">
The facets of a datatype serve to distinguish those aspects of
one datatype which <emph>differ</emph> 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 <emph>synthesis</emph> of facet values which together determine the
<termref def="dt-value-space"/> and properties of the datatype.
</p>
<p diff="del">
Facets are of two types: <emph>fundamental</emph> facets that define
the datatype and <emph>non-fundamental</emph> or <emph>constraining
</emph> facets that constrain the permitted values of a datatype.
</p>

<p diff="add"><termdef term="facet" id="dt-facet"><term>Facets</term> are designated and named
values that either provide information about an aspect of the datatype (<termref def="dt-fundamental-facet">information
facets</termref>) or control some aspect of the datatype
(<termref def="dt-constraining-facet">&cfacet;s</termref>).</termdef>&nbsp; For example, each datatype has a
<compref ref="dc-cardinality"/> facet whose 
value generally tells something about the finiteness of the datatype, and each datatype has 
a <compref ref="dc-whiteSpace"/>  facet whose value controls the &quot;normalization&quot; of the 
raw data-character string in the XML document undergoes prior to being treated as a potential 
member of the <termref def="dt-lexical-space"></termref>.</p>
				
<p diff="add">
Facets are of two kinds:&nbsp;
<termdef term="information facet" id="dt-fundamental-facet"><term>information facets</term> provide the
application with some information about the datatype</termdef>, and 
<termdef term="&cfacet;" id="dt-constraining-facet"><term>&cfacet;</term> values may be set or changed
during derivation (subject to facet-specific controls) 
and which control various aspects of the derived datatype</termdef>.&nbsp; For example, <compref ref="dc-cardinality"/> 
is an information facet and <compref ref="dc-whiteSpace"/> is a &cfacet;.&nbsp; The various information 
facets are described in <specref ref="rf-fund-facets"/> and &cfacet;s in 
<specref ref="rf-facets"/>.</p>

<!--ednote><edtext>We may require that information facets be tracked,
in which case we will change the following note accordingly.&nbsp; Similarly if we don't add the
new &cfacet;s for precisionDecimal or whatever else might need them.</edtext></ednote-->

<note diff="add">
<p> In the 1.0 version of this specification, information facets were called 
&quot;fundamental facets&quot;<!-- and &cfacet;s were called &quot;constraining 
facets&quot;-->.&nbsp; Information facets are not required for schema processing,
but some applications use them.<!--&nbsp; More &cfacet;s have been added which do 
not constrain the value space of derived datatypes (and the whitespace facet never did).--></p>
</note>

<div3 id="fundamental-facets-delled" diff="del">
<head>Fundamental facets</head>
<p>
<termdef id="dt-fundamental-facet-delled" term="fundamental facet">
A <term>fundamental facet</term> is an abstract property which
serves to semantically characterize the values in a
<termref def="dt-value-space"/>.
</termdef>
</p>
<p>
All <term>fundamental facets</term> are fully described in
<specref ref="rf-fund-facets"/>.
</p>
</div3>

<div3 id="non-fundamental-delled" diff="del">
<head>Constraining or Non-fundamental facets</head>
<p>
<termdef id="dt-constraining-facet-delled" term="constraining facet">A
<term>constraining facet</term> is an optional property that can be
applied to a datatype to constrain its <termref def="dt-value-space"/>.
</termdef>
</p>
<p>
Constraining the <termref def="dt-value-space"/> consequently constrains
the <termref def="dt-lexical-space"/>.&nbsp; Adding
<termref def="dt-constraining-facet"/>s to a <termref def="dt-basetype"/>
is described in <specref ref="derivation-by-restriction"/>.
</p>
<p>
All <term>constraining facets</term> are fully described in
<specref ref="rf-facets"/>.
</p>

</div3>
</div2>

 <!-- ****************************** END NEW 1.1 MATERIAL (DATATYPES/FACETS) ********************************* -->

<div2 role="1.0" id="datatype-dichotomies">
<head>Datatype dichotomies</head>
<p>
It is useful to categorize the datatypes defined in this specification
along various dimensions, forming a set of characterization dichotomies.
</p>
<div3 role="1.0" id="atomic-vs-list">
<head>Atomic vs. list vs. union datatypes</head>
<p>
The first distinction to be made is that between
<termref def="dt-atomic"/>, <termref def="dt-list"/> and <termref def="dt-union"/>
datatypes.
</p>
<ulist>
<item>
<p>
<termdef id="dt-atomic" term="atomic"><term>Atomic</term> datatypes
are those having values which are regarded by this specification as
being indivisible.
</termdef>
</p>
</item>
<item>
<p>
<termdef id="dt-list" term="list"><term>List</term>
datatypes are those having values each of which consists of a
finite-length (possibly empty) sequence of values of an
<termref def="dt-atomic"/> datatype.
</termdef>
</p>
</item>
<item>
<p>
<termdef id="dt-union" term="union"><term>Union</term>
datatypes are those whose <termref def="dt-value-space"/>s and
<termref def="dt-lexical-space"/>s are the union of
the <termref def="dt-value-space"/>s and
<termref def="dt-lexical-space"/>s of one or more other datatypes.
</termdef>
</p>
</item>
</ulist>
<p>
For example, a single token which <termref def="dt-match"/>es
<xspecref href="&xmlspec;#NT-Nmtoken">Nmtoken</xspecref> from
<bibref ref="XML"/> could be the value of an <termref def="dt-atomic"/>
datatype (<dtref ref="NMTOKEN"/>); while a sequence of such tokens
could be the value of a <termref def="dt-list"/> datatype
(<dtref ref="NMTOKENS"/>).
</p>
<div4 role="1.0" id="atomic">
<head>Atomic datatypes</head>
<p>
<termref def="dt-atomic"/> datatypes can be either
<termref def="dt-primitive"/> or <termref def="dt-derived"/>.&nbsp; The
<termref def="dt-value-space"/> of an <termref def="dt-atomic"/> datatype
is a set of "atomic" values, which for the purposes of this specification,
are not further decomposable.&nbsp; The <termref def="dt-lexical-space"/> of
an <termref def="dt-atomic"/> datatype is a set of <emph>literals</emph>
whose internal structure is specific to the datatype in question.
</p>
</div4>
<div4 role="1.0" id="list-datatypes">
<head>List datatypes</head>
<!-- question: are lists ordered? answer should be NO...the sequence
within a single value is ordered, but the value space is a list type
is not ordered
-->
<p>
Several type systems (such as the one described in
<bibref ref="ISO11404"/>) treat <termref def="dt-list"/> datatypes as
special cases of the more general notions of aggregate or collection
datatypes.
</p>
<p>
<termref def="dt-list"/> datatypes are always <termref def="dt-derived"/>.
The <termref def="dt-value-space"/> of a <termref def="dt-list"/>
datatype is a set of finite-length sequences of <termref def="dt-atomic"/>
values. The <termref def="dt-lexical-space"/> of a
<termref def="dt-list"/> datatype is a set of literals whose internal
structure is a space-separated
sequence of literals of the
<termref def="dt-atomic"/> datatype of the items in the
<termref def="dt-list"/>.
</p>
<p>
<termdef id="dt-itemType" term="itemType">
The <termref def="dt-atomic"/> or <termref def="dt-union"/>
datatype that participates in the definition of a <termref def="dt-list"/> datatype
is known as the <term>itemType</term> of that <termref def="dt-list"/> datatype.
</termdef>
</p>
<note role="example">
<eg><![CDATA[
<simpleType name='sizes'>
  <list itemType='decimal'/>
</simpleType>
]]></eg>
<eg><![CDATA[
<cerealSizes xsi:type='sizes'> 8 10.5 12 </cerealSizes>
]]></eg>
</note>
<p>
A <termref def="dt-list"/> datatype can be <termref def="dt-derived"/>
from an <termref def="dt-atomic"/> datatype whose
<termref def="dt-lexical-space"/> allows space
(such as <dtref ref="string"/>
or <dtref ref="anyURI"/>)or a
	<termref def="dt-union"/> datatype any of whose <propref ref="defn-memberTypes"/>'s
	<termref def="dt-lexical-space"/> allows space.
In such a case, regardless of the input, list items
will be separated at space boundaries.
</p>

<note role="example">
<eg><![CDATA[
<simpleType name='listOfString'>
  <list itemType='string'/>
</simpleType>
]]></eg>
<eg>
&lt;someElement xsi:type='listOfString'>
this is not list item 1
this is not list item 2
this is not list item 3
&lt;/someElement>
</eg>
<p>
In the above example, the value of the <emph>someElement</emph> element
is not a <termref def="dt-list"/> of <termref def="dt-length"/> 3;
rather, it is a <termref def="dt-list"/> of <termref def="dt-length"/>
18.
</p>
</note>
<!--
     somehow need to get the <has-facets> concept for abstract lists
	 into builtin.xsd, so that the following can be auto-generated
  -->
<p>
When a datatype is <termref def="dt-derived"/> from a
<termref def="dt-list"/> datatype, the following
<termref def="dt-constraining-facet"/>s apply:
</p>
<ulist>
<item><p><termref def="dt-length"/></p></item>
<item><p><termref def="dt-maxLength"/></p></item>
<item><p><termref def="dt-minLength"/></p></item>
<item><p><termref def="dt-enumeration"/></p></item>
<item><p><termref def="dt-pattern"/></p></item>
<item><p><termref def="dt-whiteSpace"/></p></item>
</ulist>
<p>
For each of <termref def="dt-length"/>, <termref def="dt-maxLength"/>
and <termref def="dt-minLength"/>, the <emph>unit of length</emph> is
measured in number of list items.&nbsp; The value of <termref def="dt-whiteSpace"/>
is fixed to the value <emph>collapse</emph>.
</p>
<p>

For <termref def="dt-list"/> datatypes the <termref def="dt-lexical-space"/>

is composed of space-separated
literals of its <termref def="dt-itemType"/>.&nbsp; Hence, any
<termref def="dt-pattern"/> specified when a new datatype is
<termref def="dt-derived"/> from a <termref def="dt-list"/> datatype is matched against
each literal of the <termref def="dt-list"/> datatype and
not against the literals of the datatype that serves as its
<termref def="dt-itemType"/>.

</p>
<note role="example">
<eg>
<![CDATA[<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>
]]>
</eg>
</note>
<p>
The <dtref ref="canonical-lexical-representation"/> for the
<termref def="dt-list"/> datatype is defined as the lexical form in which
each item in the <termref def="dt-list"/> has the canonical lexical
representation of its  <termref def="dt-itemType"/>.
</p>
</div4>
<div4 role="1.0" id="union-datatypes">
<head>Union datatypes</head>
<p>
The <termref def="dt-value-space"/> and <termref def="dt-lexical-space"/>
of a <termref def="dt-union"/> datatype are the union of the
<termref def="dt-value-space"/>s and <termref def="dt-lexical-space"/>s of
its <termref def="dt-memberTypes"/>.
<termref def="dt-union"/> datatypes are always <termref def="dt-derived"/>.
Currently, there are no <termref def="dt-built-in"/>&nbsp;<termref def="dt-union"/>
datatypes.
</p>
<note role="example">
<p>
A prototypical example of a <termref def="dt-union"/> type is the
<xspecref href="&xsdl;#p-max_occurs">maxOccurs attribute</xspecref> on the
<xspecref href="&xsdl;#element-element">element element</xspecref>
in XML Schema itself: it is a union of nonNegativeInteger
and an enumeration with the single member, the string "unbounded", as shown below.
</p>
<eg><![CDATA[
  <attributeGroup name="occurs">
    <attribute name="minOccurs" type="nonNegativeInteger"]]>
    	use="optional"<![CDATA[ default="1"/>
    <attribute name="maxOccurs"]]>use="optional" default="1"<![CDATA[>
      <simpleType>
        <union>
          <simpleType>
            <restriction base='nonNegativeInteger'/>
          </simpleType>
          <simpleType>
            <restriction base='string'>
              <enumeration value='unbounded'/>
            </restriction>
          </simpleType>
        </union>
      </simpleType>
    </attribute>
  </attributeGroup>
]]></eg>
</note>
<p>
Any number (greater than 1) of <termref def="dt-atomic"/> or <termref def="dt-list"/>
<termref def="dt-datatype"/>s can participate in a <termref def="dt-union"/> type.
</p>
<p>
<termdef id="dt-memberTypes" term="memberTypes">
The datatypes that participate in the
definition of a <termref def="dt-union"/> datatype are known as the
<term>memberTypes</term> of that <termref def="dt-union"/> datatype.
</termdef>
</p>
<p>
The order in which the <termref def="dt-memberTypes"/> are specified in the
definition (that is, the order of the &lt;simpleType> children of the &lt;union>
element, or the order of the <dtref ref="QName"/>s in the <emph>memberTypes</emph>
attribute) is significant.
During validation, an element or attribute's value is validated against the
<termref def="dt-memberTypes"/> in the order in which they appear in the
definition until a match is found.&nbsp; The evaluation order can be overridden
with the use of <xspecref href="&xsdl;#xsi_type">xsi:type</xspecref>.
</p>
<note>
<p>
For example, given the definition below, the first instance of the &lt;size> element
validates correctly as an <specref ref="integer"/>, the second and third as
<specref ref="string"/>.
</p>
<eg><![CDATA[
  <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>
]]></eg>
<eg><![CDATA[
  <size>1</size>
  <size>large</size>
  <size xsi:type='xsd:string'>1</size>
]]></eg></note>
<p> The <dtref ref="canonical-lexical-representation"/> for a
<termref def="dt-union"/> datatype is defined as the lexical form in which
the values have the canonical lexical representation
of the appropriate  <termref def="dt-memberTypes"/>.</p>
<note>
<p>
A datatype which is <termref def="dt-atomic"/> in this specification
need not be an "atomic" datatype in any programming language used to
implement this specification.&nbsp; Likewise, a datatype which is a
<termref def="dt-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 <termref def="dt-union"/> in this
specification need not be a "union" datatype in any programming
language used to implement this specification.
</p>
</note>
</div4>
</div3>
<div3 role="1.0" id="primitive-vs-derived">
<head>Primitive vs. derived datatypes</head>
<p>
Next, we distinguish between <termref def="dt-primitive"/> and
<termref def="dt-derived"/> datatypes.
</p>
<ulist>
<item>
<p>
<termdef id="dt-primitive" term="primitive"><term>Primitive</term>
datatypes are those that are not defined in terms of other datatypes;
they exist <emph>ab initio</emph>.
</termdef>
</p>
</item>
<item>
<p>
<termdef id="dt-derived" term="derived"><term>Derived</term>
datatypes are those that are defined in terms of other datatypes.
</termdef>
</p>
</item>
</ulist>
<p>
For example, in this specification, <dtref ref="float"/> is a well-defined
mathematical
<!-- find example other than float -->
concept that cannot be defined in terms of other datatypes, while
a <dtref ref="integer"/> is a special case of the more general datatype
<dtref ref="decimal"/>.
</p>
<issue id="RQ-141i" role="1.1">
<p><loc href="&reqs;#anyAtomicType" target="reqs">RQ-141 (add abstract anyAtomicType)</loc>
<loc href="&reqs;#fundamentals" target="reqs">RQ-24 (systematic facets: status and value space of anySimpleType)</loc></p>
<p>A new "magic" datatype will be introduced as a child of anySimpleType and the parent of all primitive atomic datatypes.</p>
</issue>
<p>
<termdef id="dt-anySimpleType" term="anySimpleType" role="local">
The simple ur-type definition is a special restriction of the
<xtermref href="&xsdl;#key-urType">ur-type definition</xtermref>
whose name is <term>anySimpleType</term> in the XML Schema namespace.
<term>anySimpleType</term> can be
considered as the <termref def="dt-basetype"/> of all <termref def="dt-primitive"/>
datatypes.
<term>anySimpleType</term> is considered to have an unconstrained lexical space and a
<termref def="dt-value-space"/> consisting of the union of the
<termref def="dt-value-space"/>s of all the
<termref def="dt-primitive"/>
datatypes and the set of all lists of all members of the
<termref def="dt-value-space"/>s of all the
<termref def="dt-primitive"/> datatypes.
</termdef>
</p>
<p>
The datatypes defined by this specification fall into both
the <termref def="dt-primitive"/> and <termref def="dt-derived"/>
categories.&nbsp; It is felt that a judiciously chosen set of
<termref def="dt-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
<termref def="dt-derived"/>.
</p>
<p>
In the example above, <dtref ref="integer"/> is <termref def="dt-derived"/>
from <dtref ref="decimal"/>.
</p>
<note>
<p>
A datatype which is <termref def="dt-primitive"/> in this specification
need not be a "primitive" datatype in any programming language used to
implement this specification.&nbsp; Likewise, a datatype which is
<termref def="dt-derived"/> in this specification need not be a
"derived" datatype in any programming language used to implement
this specification.
</p>
</note>
<p>
As described in more detail in <specref ref="xr-defn"/>,
each <termref def="dt-user-derived"/> datatype <termref def="dt-must"/>
be defined in terms of another datatype in one of three ways: 1) by assigning
<termref def="dt-constraining-facet"/>s which serve to <emph>restrict</emph> the
<termref def="dt-value-space"/> of the <termref def="dt-user-derived"/>
datatype to a subset of that of the <termref def="dt-basetype"/>; 2) by creating
a <termref def="dt-list"/> datatype whose <termref def="dt-value-space"/>
consists of finite-length sequences of values of its
<termref def="dt-itemType"/>; or 3) by creating a <termref def="dt-union"/>
datatype whose <termref def="dt-value-space"/> consists of the union of the
<termref def="dt-value-space"/>s of its <termref def="dt-memberTypes"/>.
</p>

<div4 role="1.0" id="restriction">
<head>Derived by restriction</head>
<p>
<!-- add the exception for pattern -->
<termdef id="dt-restriction" term="restriction">A datatype is said to be
<termref def="dt-derived"/> by <term>restriction</term> from another datatype
when values for zero or more <termref def="dt-constraining-facet"/>s are specified
that serve to constrain its <termref def="dt-value-space"/> and/or its
<termref def="dt-lexical-space"/> to a subset of those of its
<termref def="dt-basetype"/>.
</termdef>
</p>
<p>
<termdef id="dt-basetype" term="base type">Every
datatype that is <termref def="dt-derived"/> by <term>restriction</term>
is defined in terms of an existing datatype, referred to as its
<term>base type</term>. <term>base type</term>s can be either
<termref def="dt-primitive"/> or <termref def="dt-derived"/>.
</termdef>
</p>
</div4>
<div4 role="1.0" id="list">
<head>Derived by list</head>
<p>
A <termref def="dt-list"/> datatype can be <termref def="dt-derived"/>
from another datatype (its <termref def="dt-itemType"/>) by creating
a <termref def="dt-value-space"/> that consists of a finite-length sequence
of values of its <termref def="dt-itemType"/>.
</p>
</div4>
<div4 role="1.0" id="union">
<head>Derived by union</head>
<p>
One datatype can be <termref def="dt-derived"/> from one or more
datatypes by <termref def="dt-union"/>ing their <termref def="dt-value-space"/>s
and, consequently, their <termref def="dt-lexical-space"/>s.
</p>
</div4>
</div3>
<div3 role="1.0" id="built-in-vs-user-derived">
<head>Built-in vs. user-derived datatypes</head>
<ulist>
<item>
<p>
<termdef id="dt-built-in" term="built-in"><term>Built-in</term>
datatypes are those which are defined in this specification,
and can be either <termref def="dt-primitive"/> or
<termref def="dt-derived"/>;
</termdef>
</p>
</item>
<item>
<p>
<termdef id="dt-user-derived" term="user-derived">
<term>User-derived</term> datatypes are those <termref def="dt-derived"/>
datatypes that are defined by individual schema designers.
</termdef>
</p>
</item>
</ulist>
<p>
Conceptually there is no difference between the
<termref def="dt-built-in"/>&nbsp;<termref def="dt-derived"/> datatypes
included in this specification and the <termref def="dt-user-derived"/>
datatypes which will be created by individual schema designers.
The <termref def="dt-built-in"/>&nbsp;<termref def="dt-derived"/> 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" them.&nbsp; Furthermore, including these
<termref def="dt-derived"/> datatypes in this specification serves to
demonstrate the mechanics and utility of the datatype generation
facilities of this specification.
</p>
<note>
<p>
A datatype which is <termref def="dt-built-in"/> in this specification
need not be a "built-in" datatype in any programming language used
to implement this specification.&nbsp; Likewise, a datatype which is
<termref def="dt-user-derived"/> in this specification need not
be a "user-derived" datatype in any programming language used to
implement this specification.
</p>
</note>
</div3>
</div2>
</div1>
<div1 role="1.0" id="built-in-datatypes">
<head>Built-in datatypes</head>
<graphic source="type-hierarchy.gif" alt="Diagram of built-in type hierarchy" map="typeImage"/>
<!--
	thanx to Asir S Vedamuthu for creating this image map
  -->
  <imagemap source="image-map.html" id="typeImage"/>

<p>
      Each built-in datatype in this specification (both
      <termref def="dt-primitive"/> and
      <termref def="dt-derived"/>) can be uniquely addressed via a
      URI Reference constructed as follows:
</p>
<olist>
<item><p>the base URI is the URI of the XML Schema namespace</p></item>
<item><p>the fragment identifier is the name of the datatype</p></item>
</olist>
<p>
      For example, to address the <dtref ref="int"/> datatype, the URI is:
</p>
<ulist>
      <item><p><code>http://www.w3.org/2001/XMLSchema#int</code></p></item>
</ulist>
<p>
      Additionally, each facet definition element can be uniquely
      addressed via a URI constructed as follows:
</p>
<olist>
<item><p>the base URI is the URI of the XML Schema namespace</p></item>
<item><p>the fragment identifier is the name of the facet</p></item>
</olist>
<p>
      For example, to address the maxInclusive facet, the URI is:
</p>
<ulist>
      <item><p><code>http://www.w3.org/2001/XMLSchema#maxInclusive</code></p></item>
</ulist>
<p>
      Additionally, each facet usage in a built-in datatype definition
      can be uniquely addressed via a URI constructed as follows:
</p>
<olist>
<item><p>the base URI is the URI of the XML Schema namespace</p></item>
<item><p>the fragment identifier is the name of the datatype, followed
	by a period (".") followed by the name of the facet</p></item>
</olist>
<p>
      For example, to address the usage of the maxInclusive facet in
      the definition of int, the URI is:
</p>
<ulist>
      <item><p><code>http://www.w3.org/2001/XMLSchema#int.maxInclusive</code></p></item>
</ulist>
<div2 role="1.0" id="namespaces">
<head>Namespace considerations</head>
<p>
The <termref def="dt-built-in"/> datatypes defined by this specification
are designed to be used with the &schema-language; as well as other
XML specifications.
To facilitate usage within the &schema-language;, the <termref def="dt-built-in"/>
datatypes in this specification have the namespace name:
</p>
<ulist>
<item><p>http://www.w3.org/2001/XMLSchema</p></item>
</ulist>
<p>
To facilitate usage in specifications other than the &schema-language;,
such as those that do not want to know anything about aspects of the
&schema-language; other than the datatypes, each <termref def="dt-built-in"/>
datatype is also defined in the namespace whose URI is:
</p>
<ulist>
<item><p>http://www.w3.org/2001/XMLSchema-datatypes</p></item>
</ulist>
<p>
This applies to both
<termref def="dt-built-in"/>&nbsp;<termref def="dt-primitive"/> and
<termref def="dt-built-in"/>&nbsp;<termref def="dt-derived"/> datatypes.
</p>
<p>
Each <termref def="dt-user-derived"/> datatype is also associated with a
unique namespace.&nbsp; However, <termref def="dt-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
(see <xspecref href="&xsdl;#declare-schema">XML Representation of
Schemas</xspecref> in <bibref ref="structural-schemas"/>).
</p>
</div2>
<div2 role="1.0" id="built-in-primitive-datatypes">
<head>Primitive datatypes</head>
<p>
The <termref def="dt-primitive"/> datatypes defined by this specification
are described below.&nbsp; For each datatype, the
<termref def="dt-value-space"/> and <termref def="dt-lexical-space"/>
are defined, <termref def="dt-constraining-facet"/>s which apply
to the datatype are listed and any datatypes <termref def="dt-derived"/>
from this datatype are specified.
</p>
<p>
<termref def="dt-primitive"/> datatypes can only be added by revisions
to this specification.
</p>
<div3 role="1.0" id="string">
<head>string</head>
<p>
<termdef id="dt-string" term="string" role="local">The <term>string</term> datatype
represents character strings in XML.&nbsp; The <termref def="dt-value-space"/>
of <term>string</term> is the set of finite-length sequences of
<xtermref href="&xmlspec;#dt-character">character</xtermref>s (as defined in
<bibref ref="XML"/>) that <termref def="dt-match"/> the
<xnt href="&xmlspec;#NT-Char">Char</xnt> production from <bibref ref="XML"/>.
A <xtermref href="&xmlspec;#dt-character">character</xtermref> is an atomic unit of
communication; it is not further specified except to note that every
<xtermref href="&xmlspec;#dt-character">character</xtermref> has a corresponding
Universal Character Set code point, which is an integer.
</termdef>
</p>
<note>
<p>
Many human languages have writing systems that require
child elements for control of aspects such as bidirectional formating or
ruby annotation (see <bibref ref="ruby"/> and Section 8.2.4
<xspecref href="&html4;struct/dirlang.html#h-8.2.4">Overriding the
bidirectional algorithm: the BDO element</xspecref> of <bibref ref="html4"/>).
Thus, <term>string</term>, 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
<xspecref href="http://www.w3.org/TR/2001/REC-xmlschema-0-20010502/#textType">Any Element, Any Attribute</xspecref>
of <bibref ref="schema-primer"/>.
</p>
</note>
<note>
<p>
As noted in <compref ref="dc-ordered"/>, the fact that this specification does
not specify an <termref def="dt-order-relation"/> for <termref def="dt-string"/>
does not preclude other applications from treating strings as being ordered.
</p>
</note>
<div4 role="1.0" id="string-facets">
<head>Constraining facets</head>
<facets/>
</div4>
<div4 role="1.0" id="string-derived-types">
<head>Derived datatypes</head>
<subtypes/>
</div4>
</div3>
<div3 role="1.0" id="boolean">
<head>boolean</head>
<p>
<termdef id="dt-boolean" term="boolean" role="local"><term>boolean</term> has the
<termref def="dt-value-space"/> required to support the mathematical
concept of binary-valued logic: {true, false}.</termdef>
</p>
<div4 role="1.0" id="boolean-lexical-representation">
<head>Lexical representation</head>
<p>
An instance of a datatype that is defined as <termref def="dt-boolean"/>
can have the following legal literals {true, false, 1, 0}.
</p>
</div4>
<div4 role="1.0" id="boolean-canonical-representation">
<head>Canonical representation</head>
<p>
The canonical representation for <term>boolean</term> is the set of
literals {true, false}.
</p>
</div4>
<div4 role="1.0" id="boolean-facets">
<head>Constraining facets</head>
<facets/>
</div4>
</div3>
<div3 role="1.0" id="decimal">
<head>decimal</head>

<issue id="RQ-150i" role="1.1">
<p><loc href="&reqs;#composition" target="reqs">RQ-150 (minimum nbr of digits for decimal)</loc></p>
<p>The minimum will be lowered to 16 digits; a health warning
will be added to indicate that optimized implementations of derived
datatypes may exceed the limits of the base, but are not required
to.</p>
</issue>

<p>
<termdef id="dt-decimal" term="decimal" role="local"><term>decimal</term>
represents a subset of the real numbers, which can be represented by decimal numerals.
The <termref def="dt-value-space"/> of <term>decimal</term>
is the set of 
numbers that can be obtained by multiplying an integer by a non-positive
power of ten, i.e., expressible as <emph role="eq">i &times; 10^-n</emph>
where <emph role="eq">i</emph> and <emph role="eq">n</emph> are integers
and <emph role="eq">n >= 0</emph>.
Precision is not reflected in this value space;
the number 2.0 is not distinct from the number 2.00.
The <termref def="dt-order-relation"/> on <term>decimal</term>
is the order relation on real numbers, restricted
to this subset.
</termdef>
</p>
<p>

</p>
<p>

</p>
<note>
<p>
All <termref def="dt-minimally-conforming"/> processors <termref def="dt-must"/>
support decimal numbers with a minimum of 18 decimal digits (i.e., with a
<termref def="dt-totalDigits"/> of 18).&nbsp; However,
<termref def="dt-minimally-conforming"/> processors <termref def="dt-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 <termref def="dt-must"/> be clearly documented.
</p>
</note>
<div4 role="1.0" id="decimal-lexical-representation">
<head>Lexical representation</head>
<p>
<term>decimal</term> has a lexical representation
consisting of a 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.&nbsp; Leading and trailing zeroes are optional.
If the fractional part is zero, the period and following zero(es) can
be omitted.
For example: <code>-1.23, 12678967.543233, +100000.00, 210</code>.
</p>
</div4>
<div4 role="1.0" id="decimal-canonical-representation">
<head>Canonical representation</head>
<p>
The canonical representation for <term>decimal</term> is defined by
prohibiting certain options from the
<specref ref="decimal-lexical-representation"/>.&nbsp; Specifically, the preceding
optional "+" sign is prohibited.&nbsp; 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.
</p>
</div4>
<div4 role="1.0" id="decimal-facets">
<head>Constraining facets</head>
<facets/>
</div4>
<div4 role="1.0" id="decimal-derived-types">
<head>Derived datatypes</head>
<subtypes/>
</div4>
</div3>

<div3 role="1.0" id="float">
<head>float</head>

<issue id="RQ-1i" role="1.1">
<p><loc href="&reqs;#canonical-float" target="reqs">RQ-1 (canonical representation of float, double)</loc></p>
<p>The description of canonical representations for float and double needs to be cleaned up.</p>
</issue>

<issue id="RQ-140i" role="1.1">
<p><loc href="&reqs;#negative-positive-zero" target="reqs">RQ-140 (positive and negative zero in float and double)</loc></p>
<p>Two zeros will be provided similar to those in precisionDecimal</p>
</issue>

<p>
<termdef id="dt-float" term="float" role="local"><term>float</term>
is patterned after the IEEE single-precision 32-bit floating point type
<bibref ref="ieee754"/>.&nbsp; The basic <termref def="dt-value-space"/> of
<term>float</term> consists of the values
<emph role="eq">m &times; 2^e</emph>, where <emph role="eq">m</emph>
is an integer whose absolute value is less than
<emph role="eq">2^24</emph>, and <emph role="eq">e</emph> is an integer
between -149 and 104, inclusive.&nbsp; In addition to the basic
<termref def="dt-value-space"/> described above, the
<termref def="dt-value-space"/> of <term>float</term> also contains the
following
three
<emph>special values</emph>:

positive and negative infinity and not-a-number
(NaN).
The <termref def="dt-order-relation"/> on <term>float</term>
is: <emph role="eq">x &lt; y iff y - x</emph> 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 <termref def="dt-value-space"/>.

</termdef>
</p>

<note>
<p>

"Equality" in this Recommendation is defined to be "identity" (i.e., values that
are identical in the <termref def="dt-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; <bibref ref="ieee754"/>-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.

</p>

<p>

Any value incomparable with the value used for the four bounding facets
(<termref def="dt-minInclusive"/>, <termref def="dt-maxInclusive"/>,
<termref def="dt-minExclusive"/>, and <termref def="dt-maxExclusive"/>) will be
excluded from the resulting restricted <termref def="dt-value-space"/>. In particular,
when "NaN" is used as a facet value for a bounding facet, since no other
<term>float</term> values are <termref def="dt-comparable"/> with it, the result is a <termref def="dt-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 <termref def="dt-value-space"/>;
to add NaN back in requires union with the NaN-only space.

</p>

<p>

This datatype differs from that of <bibref ref="ieee754"/> 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 <bibref ref="ieee754"/> only in that for schema purposes NaN = NaN.

</p>
</note>

<p>
A literal in the <termref def="dt-lexical-space"/> representing a
decimal number <emph role="eq">d</emph> maps to the normalized value
in the <termref def="dt-value-space"/> of <term>float</term> that is
closest to <emph role="eq">d</emph> in the sense defined by
<bibref ref="clinger1990"/>; if <emph role="eq">d</emph> is
exactly halfway between two such values then the even value is chosen.
</p>
<div4 role="1.0" id="float-lexical-representation">
<head>Lexical representation</head>
<p>
<term>float</term> values have a lexical representation
consisting of a mantissa followed, optionally, by the character
"E" or "e", followed by an exponent.&nbsp; The exponent <termref def="dt-must"/>
be an <dtref ref="integer"/>. The mantissa must be a  <dtref ref="decimal"/> number. The representations
for exponent and mantissa must follow the lexical rules for
<dtref ref="integer"/> and <dtref ref="decimal"/>.&nbsp; If the "E" or "e" and
the following exponent are omitted, an exponent value of 0 is assumed.
</p>
<p>
The <emph>special values</emph>

positive
and negative infinity and not-a-number have lexical representations

<code>INF</code>, <code>-INF</code> and
<code>NaN</code>, respectively.

Lexical representations for zero may take a positive or negative sign.

</p>
<p>
For example, <code>-1E4, 1267.43233E12, 12.78e-2, 12</code>
<code>, -0, 0</code>
and <code>INF</code> are all legal literals for <term>float</term>.
</p>
</div4>
<div4 role="1.0" id="float-canonical-representation">
<head>Canonical representation</head>
<p>
The canonical representation for <term>float</term> is defined by
prohibiting certain options from the
<specref ref="float-lexical-representation"/>.&nbsp; Specifically, the exponent
must be indicated by "E".&nbsp; 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.
</p>
</div4>
<div4 role="1.0" id="float-facets">
<head>Constraining facets</head>
<facets/>
</div4>
</div3>
<div3 role="1.0" id="double">
<head>double</head>
<p>
<termdef id="dt-double" term="double" role="local">The <term>double</term>
datatype
is patterned after the

IEEE double-precision 64-bit floating point
type <bibref ref="ieee754"/>.&nbsp; The basic <termref def="dt-value-space"/>
of <term>double</term> consists of the values
<emph role="eq">m &times; 2^e</emph>, where <emph role="eq">m</emph>
is an integer whose absolute value is less than
<emph role="eq">2^53</emph>, and <emph role="eq">e</emph> is an
integer between -1075 and 970, inclusive.&nbsp; In addition to the basic
<termref def="dt-value-space"/> described above, the
<termref def="dt-value-space"/> of <term>double</term> also contains
the following
three
<emph>special values</emph>:

positive and negative infinity and not-a-number
(NaN).
The <termref def="dt-order-relation"/> on <term>double</term>
is: <emph role="eq">x &lt; y iff y - x</emph> 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 <termref def="dt-value-space"/>.

</termdef>
</p>
<note>
<p>

"Equality" in this Recommendation is defined to be "identity" (i.e., values that
are identical in the <termref def="dt-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; <bibref ref="ieee754"/>-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.

</p>

<p>

Any value incomparable with the value used for the four bounding facets
(<termref def="dt-minInclusive"/>, <termref def="dt-maxInclusive"/>,
<termref def="dt-minExclusive"/>, and <termref def="dt-maxExclusive"/>) will be
excluded from the resulting restricted <termref def="dt-value-space"/>. In particular,
when "NaN" is used as a facet value for a bounding facet, since no other
<term>double</term> values are <termref def="dt-comparable"/> with it, the result is a <termref def="dt-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 <termref def="dt-value-space"/>;
to add NaN back in requires union with the NaN-only space.

</p>

<p>

This datatype differs from that of <bibref ref="ieee754"/> 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 <bibref ref="ieee754"/> only in that for schema purposes NaN = NaN.

</p>
</note>
<p>
A literal in the <termref def="dt-lexical-space"/> representing a
decimal number <emph role="eq">d</emph> maps to the normalized value
in the <termref def="dt-value-space"/> of <term>double</term> that is
closest to <emph role="eq">d</emph>; if <emph role="eq">d</emph> is
exactly halfway between two such values then the even value is chosen.
This is the <emph>best approximation</emph> of <emph role="eq">d</emph>
(<bibref ref="clinger1990"/>, <bibref ref="gay1990"/>), which is more
accurate than the mapping required by <bibref ref="ieee754"/>.
</p>
<div4 role="1.0" id="double-lexical-representation">
<head>Lexical representation</head>
<p>
<term>double</term> values have a lexical representation
consisting of a mantissa followed, optionally, by the character "E" or
"e", followed by an exponent.&nbsp; The exponent <termref def="dt-must"/> be
an integer.&nbsp; The mantissa must be a decimal number. The representations
for exponent and mantissa must follow the lexical rules for
<dtref ref="integer"/> and <dtref ref="decimal"/>.&nbsp; If the "E" or "e"
and the following exponent are omitted, an exponent value of 0 is assumed.
</p>
<p>
The <emph>special values</emph>

positive
and negative infinity and not-a-number have lexical representations

<code>INF</code>, <code>-INF</code> and
<code>NaN</code>, respectively.

Lexical representations for zero may take a positive or negative sign.

</p>
<p>
For example, <code>-1E4, 1267.43233E12, 12.78e-2, 12</code>
<code>, -0, 0</code>
and <code>INF</code>
are all legal literals for <term>double</term>.
</p>
</div4>
<div4 role="1.0" id="double-canonical-representation">
<head>Canonical representation</head>
<p>
The canonical representation for <term>double</term> is defined by
prohibiting certain options from the
<specref ref="double-lexical-representation"/>.&nbsp; Specifically, the exponent
must be indicated by "E".&nbsp; 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.
</p>
</div4>
<div4 role="1.0" id="double-facets">
<head>Constraining facets</head>
<facets/>
</div4>
</div3>

<!-- ****************************** BEGIN NEW 1.1 MATERIAL (PRECISIONDECIMAL) ********************************* -->

<div3 id="precisionDecimal" diff="add"><head>precisionDecimal</head>

<issue id="RQ-31i" role="1.1">
<p><loc href="&reqs;#trailing-zeroes" target="reqs">RQ-31 (precisionDecimal)</loc></p>
<p>precisionDecimal has been added.&nbsp; It is possible that precisionDecimal will replace decimal.</p>
</issue>

<issue id="RQ-30i" role="1.1">
<p><loc href="&reqs;#negative-scale" target="reqs">RQ-30 (negative fractionDigits for decimal)</loc></p>
<p>The WG feels that having this capability for precisionDecimal will be adequate.</p>
</issue>

<issue id="RQ-28i" role="1.1">
<p><loc href="&reqs;#scientific-notn" target="reqs">RQ-28 (scientific notation for decimal)</loc></p>
<p>The WG feels that having this capability for precisionDecimal will be adequate.</p>
</issue>

<p><termdef id="dt-precisionDecimal" term="precisionDecimal">The <term>precisionDecimal</term> 
datatype is similar to <dtref ref="decimal"/>, except that each value carries with 
it a precision as well as a numeric value; it also includes special values for positive and
negative infinity and <unusual>not a number</unusual>, and differentiates between <unusual>positive
zero</unusual> and <unusual>negative zero</unusual>.</termdef>  <unusual>Precision</unusual>
is explained in <specref ref="sec-precision"/>.&nbsp; The special values are introduced to
make the datatype correspond closely to <phrase role="UNSURE">decimal datatypes whose definition
is planned for the next revision of IEEE/ANSI 754</phrase>.</p>

<div4><head>Value Space</head>

<defset><head alt="Properties of precisionDecimal Values">Properties of
<dtref ref="precisionDecimal"/> Values</head>

<vpropdef><name id="vp-pd-numVal">numericalValue</name>
<limits>a &decimal;, <pt>positiveInfinity</pt>,
<pt>negativeInfinity</pt> or <pt>notANumber</pt></limits></vpropdef>

<vpropdef><name id="vp-pd-precision">arthmeticPrecision</name>
<limits>an &integer; or <pt>absent</pt>;
<pt>absent</pt> if and only if <pfref ref="vp-pd-numVal"/> is a <dtref ref="constant"/>.</limits></vpropdef>

<vpropdef><name id="vp-pd-sign">sign</name>
<limits><pt>positive</pt>, <pt>negative</pt>, or <pt>absent</pt>;
must be <pt>positive</pt> if <pfref ref="vp-pd-numVal"/>
is positive or <pt>positiveInfinity</pt>, must be <pt>negative</pt>
if <pfref ref="vp-pd-numVal"/> is negative or <pt>negativeInfinity</pt>,
must be <pt>absent</pt> if and only if <pfref ref="vp-pd-numVal"/> is <pt>notANumber</pt></limits></vpropdef>
</defset>

<note><p>The <pfref ref="vp-pd-sign"/> property is redundant except when <pfref ref="vp-pd-numVal"/>
is zero; in other cases, the <pfref ref="vp-pd-sign"/> value is fully determined by the
<pfref ref="vp-pd-numVal"/> value.&nbsp; Code optimization may well make it desirable
to separate out the <pfref ref="vp-pd-sign"/> and the absolute value of the <pfref ref="vp-pd-numVal"/>,
which will make implementation easier, but the verbal descriptions of such things as equality
and order somewhat more complicated.</p></note><note><p>As explained below, the lexical
representation of the <dtref ref="precisionDecimal"/> value object whose <pfref ref="vp-pd-numVal"/>
is <pt>notANumber</pt> is <string>NaN</string>.&nbsp; Accordingly, in English text we
use <mention>NaN</mention> to refer to that value.&nbsp; Similarly we use <mention>INF</mention>
and <mention>&minus;INF</mention> to refer to the two value objects whose <pfref ref="vp-pd-numVal"/>
is <pt>positiveInfinity</pt> and <pt>negativeInfinity</pt>.&nbsp; These three value objects
are also informally called <quote>not-a-number</quote>, <quote>positive infinity</quote>,
and <quote>negative infinity</quote>.</p></note>

<p>Equality and order for <dtref ref="precisionDecimal"/> are defined as follows:
<ulist>
<item><p>Two numerical <dtref ref="precisionDecimal"/> values
are ordered (or equal) as their
<pfref ref="vp-pd-numVal"/> values are ordered (or equal).&nbsp; (This means the two zeros with
a given <pfref ref="vp-pd-precision"/> but different <pfref ref="vp-pd-sign"/> are <emph>equal</emph>;
negative zeros are <emph>not</emph> ordered less than positive zeros.)</p></item>
<item><p>INF is equal only to itself, and is greater than
&minus;INF and all numerical <dtref ref="precisionDecimal"/> values.</p></item>
<item><p>&minus;INF is equal only to itself, and is less than
INF and all numerical <dtref ref="precisionDecimal"/> values.</p></item>
<item><p>NaN is incomparable with all values, <emph>including itself</emph>.</p></item>
</ulist>
</p>

</div4>

<div4><head>Lexical Mapping</head>

<ednote><edtext>The <phrase role="UNSURE">notation constraining</phrase> facet has not yet been written
up.&nbsp; Its effect will be to remove some portions of the lexical mapping.</edtext></ednote>

<p><dtref ref="precisionDecimal"/>'s lexical space is the set of all 
no-decimal-point, decimal, and scientific numerals, 
plus the character strings <string>INF</string>, <string>+INF</string>, <string>-INF</string>,
and <string>NaN</string>.&nbsp; (Lexical representations of numbers 
are traditionally called <quote>numerals</quote>.)&nbsp; The <phrase role="UNSURE">notation
constraining</phrase> facet can remove any one or two of the three subsets of 
numerals, with corresponding reductions in the value space.&nbsp; Using this facet
rather than <compref ref="dc-pattern"/> will change the canonical
mapping to insure that the resulting datatype will still have canonical
representations of all its values.

<defset role="prod"><head>Lexical Space</head>
<prodgroup><prod id="nt-precDecRep"><lhs>precisionDecimalRep</lhs>
<rhs><nt def="nt-noDecNuml"/>&nbsp;| <nt def="nt-decNuml"/>&nbsp;|
<nt def="nt-sciNuml"/>&nbsp;| <nt def="nt-numSpecReps"/></rhs></prod></prodgroup>
</defset>

<defsetsum ref="defs-precDecLexmap"/>

<note><p>Canonical mappings are not used during schema processing.&nbsp; They are provided in this specification for
the benefit of other users of these datatype definitions who may find them useful, and for other specifications
which might find it useful to reference them normatively.</p>
</note>

<defsetsum ref="defs-precDecCanmap"/>
</p>
<!--
<p> <phrase role="UNSURE">The 
characters <string>+</string> and <string>-</string> are <term>sign
characters</term>.&nbsp; A numeral that begins with a sign 
character is <term>signed</term>; one that does not is <term>unsigned</term>; one 
that is either unsigned or begins with <string>-</string> 
is <term>partially-signed</term>.</phrase></p>

<p><term>Mappings to P-numbers</term>For each of the three mappings defined 
below, the mapping to P-numbers maps each numeral <var>R</var> in the 
domain to the P-number whose numerical value is v(<var>R</var>) and whose 
precision is the number of nonredundant digits in <var>R</var>,  
Only zero can have more than one such P-number; see below for the 
mapping adjustment when the numerical value of the P-number is 
zero.</p>

<ednote><edtext>In this domain, leftmost <string>0</string> digits (after the sign character, if any) other 
than the rightmost digit are <term>redundant</term>. The remaining digits 
are <term>nonredundant</term>.&nbsp; Formally (by recursion), for 
<var>s</var><var>d</var><sub><var>n</var></sub>&nbsp;.&nbsp;.&nbsp;.&nbsp;<var>d</var><sub>0</sub>: 
if&nbsp; <var>n</var>&nbsp;&gt;&nbsp;1&nbsp; and <var>d</var><sub><var>n</var></sub> 
is <string>0</string>, then <var>d</var><sub><var>n</var></sub> is 
redundant; if <var>k</var> is strictly between 0 and <var>n</var>, 
<var>d</var><sub><var>k</var></sub> is <string>0</string>, and 
<var>d</var><sub>(<var>k</var>+1)</sub> is redundant, then 
<var>d</var><sub><var>k</var></sub> is redundant; other digits are 
nonredundant.   <br/>In 
numerals <var>s</var><var>I</var><string>.</string><var>F</var> of this 
domain, the <term>redundant</term> digits are those that are redundant in 
<var>I</var><var>F</var>; the <term>nonredundant</term> digits are those that are 
nonredundant in <var>I</var><var>F</var>.&nbsp; (The redundant and 
nonredundant digits in <var>I</var><var>F</var> are defined in 
<phrase role="UNSURE">3.2.<var>x</var>.1.1</phrase>.)   <br/>In 
numerals <var>D</var><var>e</var><var>E</var> of this domain, the 
<term>redundant</term> digits are those that are redundant in either 
<var>D</var> or <var>E</var>; the <term>nonredundant</term> digits are those that 
are nonredundant in <var>D</var>.&nbsp; (The redundant and 
nonredundant digits in <var>D</var> and <var>E</var> are defined in 
<phrase role="UNSURE">3.2.<var>x</var>.1.2</phrase>,  Nonredundant digits in 
<var>E</var> are neither redundant nor nonredundant in 
<var>D</var><var>e</var><var>E</var>,  This simplifies certain related 
definitions.)</edtext></ednote><note><p>Each mapping is one-to-one modulo 
redundant digits (and sign, for aP-number zero and for P-number zeros 
when signedZeros is <pt>false</pt>).</p></note>

-->

</div4>

<div4><head>&CFacet;s</head>

<ednote><edtext>The <phrase role="UNSURE">notation constraining</phrase> facet has not yet been written
up.&nbsp; It's effect will be to remove some portions of the lexical mapping.</edtext></ednote>

<p>precisionDecimal has the following <termref def="dt-constraining-facet">&cfacet;s</termref>:

<ulist>

<item><p>fractionDigits</p></item>

<item><p>minFractionDigits</p></item>

<item><p>totalDigits</p></item>

<item><p>specials</p></item><item><p><phrase role="UNSURE">notation constraining</phrase></p></item>

<item><p>maxInclusive</p></item>

<item><p>maxExclusive</p></item>

<item><p>minInclusive</p></item>

<item><p>minExclusive</p></item>

<item><p>pattern</p></item>

<item><p>whitespace</p></item>

<item><p>eunmeration</p></item>

</ulist></p>
</div4></div3>
 
 <!-- ****************************** END NEW 1.1 MATERIAL (PRECISIONDECIMAL) ********************************* -->
 
 <!-- ********************************** BEGIN NEW 1.1 MATERIAL (DURATION) ************************************* -->
<div3 id="duration">
<head>duration</head>

<p><termdef id="dt-duration" term="duration" role="local"><term>duration</term> 
is a datatype that represents 
durations of time.</termdef>  The concept of duration being 
captured is drawn from those of <bibref ref="ISO8601"/>, specifically <emph>durations 
without fixed endpoints</emph>.&nbsp; For
example, <unusual>15 days</unusual> (whose most common lexical representation
in <dtref ref="duration"/> is 'P15D') is a <dtref ref="duration"/> value; <unusual>15 days 
beginning 12 July 1995</unusual> and <unusual>15 days ending 12 July 1995</unusual> are not.
<dtref ref="duration"/> can provide addition and subtraction operations between <dtref ref="duration"/> values 
and between <dtref ref="duration"/>/<dtref ref="dateTime"/> value pairs, and can be the result of subtracting 
<dtref ref="dateTime"/> values.&nbsp; However, only addition to and subtraction from <dtref ref="dateTime"/> 
is required for XML Schema processing and is defined in <specref ref="adding-durations-to-dateTimes"/></p>

<div4><head>Value Space</head>
<p>Durations can be modeled in at least two ways: as six-property tuples (similar to
the seven-property model used for other date/time datatypes) or as two-property tuples 
(somewhat similar to the alternative one-property timeOnTimeline model especially useful for 
<dtref ref="dateTime"/> order).&nbsp; For 
durations, it is useful to use the latter: <dtref ref="duration"/> values are two-property 
tuples.&nbsp; (Note, however, that the 
six-property model was implicitly used in Schema 1.0.&nbsp; The only effective difference to the user caused 
by this change is in the canonical representations.)&nbsp; See
<specref ref="theSevenPropertyModel"/> for more information on the seven-property model.

<defset><head>Properties of <dtref ref="duration"/> Values</head>
<vpropdef><name id="vp-du-month">month</name><dtref ref="integer"/></vpropdef>
<vpropdef><name id="vp-du-second">second</name><dtref ref="decimal"/>
<limits><termref def="dt-must">Must</termref> not be negative if <vpropref ref="vp-du-month"/> is positive, and <termref def="dt-must"></termref>
not be positive if <vpropref ref="vp-du-month"/> is negative.</limits>
</vpropdef>
</defset>

<dtref ref="duration"/> is partially ordered.&nbsp; Equality and order are defined in terms of that of 
<dtref ref="dateTime"/>, and are determined by adding each <dtref ref="duration"/> value pair 
in turn to the following four  <dtref ref="dateTime"/> values:

<ulist>
<item><p>1696-09-01T00:00:00Z</p></item>
<item><p>1697-02-01T00:00:00Z</p></item>
<item><p>1903-03-01T00:00:00Z</p></item>
<item><p>1903-07-01T00:00:00Z</p></item>
</ulist>

If all four resulting <dtref ref="dateTime"/> value pairs are 
ordered the same way (less than, equal, or greater than), then the 
original pair of <dtref ref="duration"/> values is ordered the same way; otherwise the original pair 
is incomparable.</p>

<note>
<p>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:&nbsp; 1697-02-01T00:00:00Z&nbsp;+&nbsp;P1M&nbsp;&lt;&nbsp;1697-02-01T00:00:00Z&nbsp;+&nbsp;P30D&nbsp;, 
but&nbsp; 1903-03-01T00:00:00Z&nbsp;+&nbsp;P1M&nbsp;&gt;&nbsp;1903-03-01T00:00:00Z&nbsp;+&nbsp;P30D&nbsp;, so 
that&nbsp; P1M&nbsp;&lt;&gt;&nbsp;P30D&nbsp;.&nbsp; If two <dtref ref="duration"/> values are ordered the same way 
when added to each of these four <dtref ref="dateTime"/> values, they will retain the same order when added 
to <emph>any</emph> other <dtref ref="dateTime"/> values, unless one is within a leap-second and either the other
is also or is the beginning moment of the next second&mdash;in which case, the two results will 
be equal even though the original
<dtref ref="dateTime"/> values were not.&nbsp; Therefore, two <dtref ref="duration"/> values are 
incomparable if and only if they can <emph>ever</emph> result in different orders when added to <emph>any</emph> 
<dtref ref="dateTime"/> value not within a leap-second.</p>

<p>This minor anomaly is the result of having <dtref ref="duration"/> unaware of leap-seconds while the
other date/time primitive datatypes are leap-second aware.</p>
</note>

<p>It turns out that under the definition just given, two <dtref ref="duration"/> 
values are equal if and only if they are identical.</p>

<note><p>Two totally ordered datatypes (<dtref ref="yearMonthDuration"/> and <dtref ref="dayTimeDuration"/>) 
are derived from <dtref ref="duration"/> in <specref ref="built-in-derived"/>.</p></note>

<note><p>There are many ways to implement <dtref ref="duration"/>, some of which do not base the implementation 
on the two-component model.&nbsp; This specification does not prescribe any particular implementation, as long as 
the visible results are isomorphic to those described herein.</p></note>

</div4>

<div4 id="duration-lexical-space"><head>Lexical Space</head>

<p>
The <termref def="dt-lexical-representation">lexical representations</termref> of <dtref ref="duration"/> are 
more or less based on the pattern:
<display><code>P<var>n</var>Y<var>n</var>M<var>n</var>DT<var>n</var>H<var>n</var>M<var>n</var>S</code></display>
</p>
<p>
More precisely, the <termref def="dt-lexical-space"></termref> of <dtref ref="duration"/> is the set of character 
strings that satisfy <nt def="nt-durationRep"/> as defined by the following productions:
<defset><head> Lexical Representation Fragments</head>
<prodgroup>
<prod id="nt-duYrFrag"><lhs>duYearFrag</lhs>
<rhs><nt def="nt-unsNoDecNuml"/>&nbsp;<string>Y</string></rhs></prod>
<prod id="nt-duMoFrag"><lhs>duMonthFrag</lhs>
<rhs><nt def="nt-unsNoDecNuml"/>&nbsp;<string>M</string></rhs></prod>
<prod id="nt-duDaFrag"><lhs>duDayFrag</lhs>
<rhs><nt def="nt-unsNoDecNuml"/>&nbsp;<string>D</string></rhs></prod>
<prod id="nt-duHrFrag"><lhs>duHourFrag</lhs>
<rhs><nt def="nt-unsNoDecNuml"/>&nbsp;<string>H</string></rhs></prod>
<prod id="nt-duMiFrag"><lhs>duMinuteFrag</lhs>
<rhs><nt def="nt-unsNoDecNuml"/>&nbsp;<string>M</string></rhs></prod>
<prod id="nt-duSeFrag"><lhs>duSecondFrag</lhs>
<rhs>(<nt def="nt-unsNoDecNuml"/>&nbsp;|&nbsp;<nt def="nt-unsDecNuml" diff="del"/><nt def="nt-unsFullDecNuml" diff="add"/>)&nbsp;<string>S</string></rhs></prod>

<prod id="nt-duYMFrag"><lhs>duYearMonthFrag</lhs>
<rhs>(<nt def="nt-duYrFrag"/>&nbsp;<nt def="nt-duMoFrag"/>?)&nbsp;| <nt def="nt-duMoFrag"/></rhs></prod>

<prod id="nt-duTFrag"><lhs>duTimeFrag</lhs>
<rhs><string>T</string>&nbsp;((<nt def="nt-duHrFrag"/>&nbsp;<nt def="nt-duMiFrag"/>?&nbsp;<nt def="nt-duSeFrag"/>?)&nbsp;|
(<nt def="nt-duMiFrag"/>&nbsp;<nt def="nt-duSeFrag"/>?)&nbsp;|
<nt def="nt-duSeFrag"/>)</rhs></prod>

<prod id="nt-duDTFrag"><lhs>duDayTimeFrag</lhs>
<rhs>(<nt def="nt-duDaFrag"/>&nbsp;<nt def="nt-duTFrag"/>?)&nbsp;| <nt def="nt-duTFrag"/></rhs></prod>

</prodgroup></defset>

<defset><head>Lexical Representation</head>
<prodgroup>
<prod id="nt-durationRep"><lhs>durationLexicalRep</lhs>
<rhs><string>-</string>?&nbsp;<string>P</string>&nbsp;((<nt def="nt-duYMFrag"/>&nbsp;<nt def="nt-duDTFrag"/>?)&nbsp;|&nbsp;<nt def="nt-duDTFrag"/>)</rhs></prod>
</prodgroup></defset></p>

<p>Thus, a <nt def="nt-durationRep"/> consists of one or more of a <nt def="nt-duYrFrag"/>, 
<nt def="nt-duMoFrag"/>, <nt def="nt-duDaFrag"/>, <nt def="nt-duHrFrag"/>, 
<nt def="nt-duMiFrag"/>, and/or <nt def="nt-duSeFrag"/>, in order, with letters 
<string>P</string> and <string>T</string> (and perhaps a <string>-</string>) where appropriate.</p>

<p>The <nt def="nt-durationRep"/> <phrase diff="add">production </phrase>is equivalent to this regular expression
<display role="shrink"><code>-?P(((([0-9]+Y([0-9]+M)?)|<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<ghost>(</ghost>[0-9]+M<ghost>)</ghost>&nbsp;)&nbsp;)(([0-9]+D(T(([0-9]+H([0-9]+M)?([0-9]+(\.[0-9]+)?S)?)|<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<ghost>(</ghost>[0-9]+M<ghost>)</ghost>&nbsp;([0-9]+(\.[0-9]+)?S)?)|<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<ghost>(</ghost>[0-9]+(\.[0-9]+)?S<ghost>)</ghost>&nbsp;)&nbsp;))?)|<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<ghost>(</ghost>T(([0-9]+H([0-9]+M)?([0-9]+(\.[0-9]+)?S)?)|<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<ghost>(</ghost>[0-9]+M<ghost>)</ghost>&nbsp;([0-9]+(\.[0-9]+)?S)?)|<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<ghost>(</ghost>[0-9]+(\.[0-9]+)?S<ghost>)</ghost>&nbsp;)&nbsp;)<ghost>)</ghost>&nbsp;)&nbsp;)?)|<br/>
&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<ghost>(</ghost>([0-9]+D(T(([0-9]+H([0-9]+M)?([0-9]+(\.[0-9]+)?S)?)|<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<ghost>(</ghost>[0-9]+M<ghost>)</ghost>&nbsp;([0-9]+(\.[0-9]+)?S)?)|<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<ghost>(</ghost>[0-9]+(\.[0-9]+)?S<ghost>)</ghost>&nbsp;)&nbsp;))?)|<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<ghost>(</ghost>T(([0-9]+H([0-9]+M)?([0-9]+(\.[0-9]+)?S)?)|<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<ghost>(</ghost>[0-9]+M<ghost>)</ghost>&nbsp;([0-9]+(\.[0-9]+)?S)?)|<br/>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<ghost>(</ghost>[0-9]+(\.[0-9]+)?S<ghost>)</ghost>&nbsp;)&nbsp;)<ghost>)</ghost>&nbsp;)&nbsp;<ghost>)</ghost>&nbsp;)&nbsp;)</code></display>
once you delete the 
whitespace.&nbsp; Redundant parehtheses are shown as
<unusual><ghost>ghosts</ghost></unusual>; some find them helpful in reading the expression.)
</p>

<p>The <termref def="dt-lexical-mapping"></termref> for <dtref ref="duration"/><phrase diff="add"> is</phrase> called 
<quote><pfref ref="f-durationMap"/></quote> herein<phrase diff="del">, is defined as  follows:</phrase>.

<defsetsum ref="defs-durationLexmap"/>
</p>

<note diff="add">
<p>Canonical mappings are not used during schema processing.&nbsp; They are provided in this specification
for the benefit of other users of these datatype definitions who may find them useful, and for other specifications
which might find it useful to reference them normatively.</p>
</note>

<p><termref role="the" def="dt-canonical-mapping">The canonical mapping</termref> for
<dtref ref="duration"/><phrase diff="add"> is</phrase> 
called <quote><pfref ref="f-durationCanMap"/></quote> herein<phrase diff="del">,
is defined as  follows:</phrase>.

<defsetsum ref="defs-durationCanmap"/></p>
</div4>

<div4 id="duration-facets"><head>&CFacet;s</head>
<facets/>
</div4>
</div3>
<!-- ********************************** END NEW 1.1 MATERIAL (DURATION) ************************************** -->

<div3 role="1.0" id="dateTime">
<head>dateTime</head>
<p>
<termdef id="dt-dateTime" term="dateTime" role="local">
<term>dateTime</term> 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 <term>dateTime</term>
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 <termref def="dt-value-space"/> of <dtref ref="decimal"/>,
with integers given units of seconds.
</termdef>
</p>

<p>
The <termref def="dt-value-space"/> of
<term>dateTime</term> 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 <termref def="dt-value-space"/> which lead to the
same results (i.e., are isomorphic) are of course acceptable.
</p>

<p>
All timezoned times are Coordinated Universal Time (<termref def="dt-utc"></termref>, sometimes called
"Greenwich Mean Time"). Other timezones indicated in lexical representations
are converted to <termref def="dt-utc"></termref> 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).
</p>

<note id="year-zero">
 <p>The date and time datatypes described in this recommendation were inspired
by <bibref ref="ISO8601"/>.&nbsp; '0001' is the lexical representation of the year 1 of the Common Era
(1
CE, sometimes written "AD 1" or "1 AD").&nbsp; 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").</p>

 <p>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 <code>'-'</code> is likely to change in
subsequent versions.</p>
<p>
 <bibref ref="ISO8601"/>
makes no mention of the year 0; in <bibref ref="ISO8601-1998"/>
the form '0000' was disallowed and this recommendation disallows it as well.
However, <bibref ref="ISO8601-2000"/>, which became available just as we were completing version
1.0, allows the form '0000', representing the year 1 BCE.&nbsp; 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.&nbsp; 
 It is the intention of the XML Schema
        Working Group to allow '0000' as a lexical representation in the
        <term>dateTime</term>, <term>date</term>, <term>gYear</term>, and
<term>gYearMonth</term> 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.
</p>

</note>

<note>
 <p>See the conformance note in <specref ref="year-sec-conformance"/> which
applies to this datatype as well.</p>
</note>

<div4 role="1.0" id="dateTime-lexical-representation">
<head>Lexical representation</head>

<p>
The <termref def="dt-lexical-space"/> of <term>dateTime</term> consists of
finite-length sequences of characters of the form:
<code>'-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s+)? (zzzzzz)?</code>,
where 









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

<p>
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.
</p>

<p>
For further guidance on arithmetic with <term>dateTime</term>s and durations,
see <specref ref="adding-durations-to-dateTimes"/><!--Appendix E-->.
</p>
</div4>

<div4 role="1.0" id="dateTime-canonical-representation">
<head>Canonical representation</head>

<p>
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:

 <ulist>
  <item><p>The 2-digit numeral representing the hour must not be '<code>24</code>';</p></item>
  <item><p>The fractional second string, if present, must not end in '<code>0</code>';</p></item>
  <item><p>for timezoned values, the timezone must be
represented with '<code>Z</code>'
(All timezoned <term>dateTime</term> values are <termref def="dt-utc"></termref>.).</p></item>
 </ulist>
</p>
</div4>

<div4 role="1.0" id="dateTime-timezones">
<head>Timezones</head>

<p>
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.
</p>

<p>
The lexical representation of a timezone is a string of the form:
<code>(('+' | '-') hh ':' mm) | 'Z'</code>,
where</p>
 <ulist>
  <item><p><emph>hh</emph> is a two-digit numeral (with leading zeros as required) that
represents the hours,</p></item>
  <item><p><emph>mm</emph> is a two-digit numeral that represents the minutes,</p></item>
  <item><p>'+' indicates a nonnegative duration,</p></item>
  <item><p>'-' indicates a nonpositive duration.</p></item>
 </ulist>
 <p>The mapping so defined is one-to-one, except that '+00:00', '-00:00', and 'Z'
all represent the same zero-length duration timezone, <termref def="dt-utc"></termref>; 'Z' is its canonical
representation.</p>

<p>
When a timezone is added to a <termref def="dt-utc"></termref> <term>dateTime</term>, the result is the date
and time "in that timezone".&nbsp; 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.
</p>
</div4>
<!-- end new stuff -->

<div4 role="1.0" id="dateTime-order">
<head>Order relation on dateTime</head>
<p>
<term>dateTime</term> value objects on either timeline are totally ordered by their timeOnTimeline
values; between the two timelines, <term>dateTime</term> 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.
</p>

<p>
In general, the <termref def="dt-order-relation"/> on <term>dateTime</term>
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:00<strong>Z</strong>. 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.</p>
<p>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
&amp; &quot;-14:00&quot;) means adding the timezone -14:00 to Q, where Q did not
already have a timezone. <emph>This is a logical explanation of the process. Actual
implementations are free to optimize as long as they produce the same results.</emph>
</p>
<p>
The ordering between two <term>dateTime</term>s P and Q is defined by the following
algorithm:
</p>
  <p>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
  <specref ref="adding-durations-to-dateTimes"/></p>
  <ulist>
    <item><p>Thus 2000-03-04T23:00:00+03:00 normalizes to 2000-03-04T20:00:00Z</p></item>
  </ulist>
  <p>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:</p>
  <olist>
    <item><p>For each i in {year, month, day, hour, minute, second}
      <olist>
        <item><p>If P[i] and Q[i] are both not specified, continue to the next i</p></item>
        <item><p>If P[i] is not specified and Q[i] is, or vice versa, stop and return
          P &lt;&gt; Q</p></item>
        <item><p>If P[i] &lt; Q[i], stop and return P &lt; Q</p></item>
        <item><p>If P[i] &gt; Q[i], stop and return P &gt; Q</p></item>
      </olist>
	</p>
    </item>
    <item><p>Stop and return P = Q</p></item>
  </olist>
  <p>C.Otherwise, if P contains a time zone and Q does not, compare
  as follows:
 </p>
    <olist>
      <item><p>P &lt; Q if P &lt; (Q with time zone +14:00)</p></item>
      <item><p>P > Q if P > (Q with time zone -14:00)</p></item>
      <item><p>P &lt;> Q otherwise, that is, if (Q with time zone +14:00) &lt; P &lt; (Q with time zone -14:00)</p></item>
     </olist>
   <p>D. Otherwise, if P does not contain a time zone and Q does, compare
  as follows:</p>
    <olist>
      <item><p> P &lt; Q if (P with time zone -14:00) &lt; Q.</p></item>
      <item><p> P &gt; Q if (P with time zone +14:00) &gt; Q.</p></item>
      <item><p> P &lt;> Q otherwise, that is, if (P with time zone +14:00) &lt; Q &lt; (P with time zone -14:00)</p></item>
    </olist>
<p>Examples:</p>
    <table border="1" cellspacing="0" cellpadding="4">
	<tbody>
      <tr>
        <th align="center" style="background-color: #FFFF99">Determinate</th>
        <th align="center" style="background-color: #FFFF99">Indeterminate</th>
      </tr>
      <tr>
        <td align="center">2000-01-15T00:00:00 <strong>&lt;</strong> 2000-02-15T00:00:00</td>
        <td align="center">2000-01-01T12:00:00 <strong>&lt;&gt;</strong>
          1999-12-31T23:00:00Z</td>
      </tr>
      <tr>
        <td align="center">2000-01-15T12:00:00 <strong>&lt;</strong> 2000-01-16T12:00:00Z</td>
        <td align="center">2000-01-16T12:00:00 <strong>&lt;&gt;</strong>
          2000-01-16T12:00:00Z</td>
      </tr>
      <tr>
        <td align="center">&nbsp;</td>
        <td align="center">2000-01-16T00:00:00 <strong>&lt;&gt;</strong> 2000-01-16T12:00:00Z</td>
      </tr>
      </tbody>
    </table>
</div4>
<div4 role="1.0" id="totally-ordered-instants">
<head>Totally ordered dateTimes</head>
<p>Certain derived types from <term>dateTime</term>
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.</p>
</div4>
<div4 role="1.0" id="dateTime-facets">
<head>Constraining facets</head>
<facets/>
</div4>
</div3>

<div3 role="1.0" id="time">
<head>time</head>
<p>
<termdef id="dt-time" term="time" role="local"><term>time</term>
represents an instant of time that recurs every day.&nbsp; The
<termref def="dt-value-space"/> of <term>time</term> is the space
of <emph>time of day</emph> values as defined in &sect; 5.3 of
<bibref ref="ISO8601"/>.&nbsp; Specifically, it is a set of zero-duration daily
time instances.</termdef>
</p>
<p>
Since the lexical representation allows an optional time zone
indicator, <term>time</term> 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.&nbsp; The order relation on
<term>time</term> values is the
<specref ref="dateTime-order"/> using an arbitrary date. See also
<specref ref="adding-durations-to-dateTimes"/>.&nbsp; Pairs of <term>time</term> values with or without time zone indicators are totally ordered.
</p>
 <note>
 <p>See the conformance note in <specref ref="year-sec-conformance"/> which
applies to the seconds part of this datatype as well.</p>
</note>
<div4 role="1.0" id="time-lexical-repr">
<head>Lexical representation</head>
<p>
The lexical representation for <term>time</term> is the left
truncated lexical representation for <dtref ref="dateTime"/>:
hh:mm:ss.sss with optional following time zone indicator.&nbsp; For example,
to indicate 1:20 pm for Eastern Standard Time which is 5 hours behind
Coordinated Universal Time (<termref def="dt-utc"></termref>), one would write: 13:20:00-05:00. See also
<specref ref="isoformats"/>.
</p>
</div4>
<div4 role="1.0" id="time-canonical-repr">
<head>Canonical representation</head>
<p>
The canonical representation for <term>time</term> is defined
by prohibiting certain options from the
<specref ref="time-lexical-repr"/>.&nbsp; Specifically, either the time zone must
be omitted or, if present