Please refer to the errata for this document, which may include some normative corrections.
See also translations.
This document is also available in these non-normative formats: XML, XHTML with changes since version 1.0 marked, XHTML with changes since previous Working Draft marked, Independent copy of the schema for schema documents, Independent copy of the DTD for schema documents, and List of translations.
Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark and document use rules apply.
XML Schema: Datatypes is part 2 of the specification of the XML Schema language. It defines facilities for defining datatypes to be used in XML Schemas as well as other XML specifications. The datatype language, which is itself represented in XML, provides a superset of the capabilities found in XML document type definitions (DTDs) for specifying datatypes on elements and attributes.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
This W3C Recommendation specifies the W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes. It is here made available for review by W3C members and the public.
Changes since the previous public Working Draft include the following:
For those primarily interested in the changes since version 1.0, the appendix Changes since version 1.0 (§I) is the recommended starting point. An accompanying version of this document displays in color all changes to normative text since version 1.0; another shows changes since the previous Working Draft.
Comments on this document should be made in W3C's public installation of Bugzilla, specifying "XML Schema" as the product. Instructions can be found at http://www.w3.org/XML/2006/01/public-bugzilla. If access to Bugzilla is not feasible, please send your comments to the W3C XML Schema comments mailing list, www-xml-schema-comments@w3.org (archive) and note explicitly that you have not made a Bugzilla entry for the comment. Each Bugzilla entry and email message should contain only one comment.
This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web.
An implementation report for XSD 1.1 was prepared and used in the Director's decision to publish the previous version of this specification as a Proposed Recommendation. The Director's decision to publish this document as a W3C Recommendation is based on consideration of reviews of the Proposed Recommendation by the public and by the members of the W3C Advisory committee.
The W3C XML Schema Working Group intends to process comments made about this recommendation, with any approved changes being handled as errata to be published separately.
This document has been produced by the W3C XML Schema Working Group as part of the W3C XML Activity. The goals of the XML Schema language version 1.1 are discussed in the Requirements for XML Schema 1.1 document. The authors of this document are the members of the XML Schema Working Group. Different parts of this specification have different editors.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
The English version of this specification is the only normative version. Information about translations of this document is available at http://www.w3.org/2003/03/Translations/byTechnology?technology=xmlschema.
The Working Group has two main goals for this version of W3C XML Schema:
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:
The overall aim as regards compatibility is that
The [XML] specification defines limited facilities for applying datatypes to document content in that documents may contain or refer to DTDs that assign types to elements and attributes. However, document authors, including authors of traditional documents and those transporting data in XML, often require a higher degree of type checking to ensure robustness in document understanding and data interchange.
The table below offers two typical examples of XML instances in which datatypes are implicit: the instance on the left represents a billing invoice, the instance on the right a memo or perhaps an email message in XML.
Data oriented | Document oriented |
---|---|
<invoice> <orderDate>1999-01-21</orderDate> <shipDate>1999-01-25</shipDate> <billingAddress> <name>Ashok Malhotra</name> <street>123 Microsoft Ave.</street> <city>Hawthorne</city> <state>NY</state> <zip>10532-0000</zip> </billingAddress> <voice>555-1234</voice> <fax>555-4321</fax> </invoice> |
<memo importance='high' date='1999-03-23'> <from>Paul V. Biron</from> <to>Ashok Malhotra</to> <subject>Latest draft</subject> <body> We need to discuss the latest draft <emph>immediately</emph>. Either email me at <email> mailto:paul.v.biron@kp.org</email> or call <phone>555-9876</phone> </body> </memo> |
The invoice contains several dates and telephone numbers, the postal abbreviation for a state (which comes from an enumerated list of sanctioned values), and a ZIP code (which takes a definable regular form). The memo contains many of the same types of information: a date, telephone number, email address and an "importance" value (from an enumerated list, such as "low", "medium" or "high"). Applications which process invoices and memos need to raise exceptions if something that was supposed to be a date or telephone number does not conform to the rules for valid dates or telephone numbers.
In both cases, validity constraints exist on the content of the instances that are not expressible in XML DTDs. The limited datatyping facilities in XML have prevented validating XML processors from supplying the rigorous type checking required in these situations. The result has been that individual applications writers have had to implement type checking in an ad hoc manner. This specification addresses the need of both document authors and applications writers for a robust, extensible datatype system for XML which could be incorporated into XML processors. As discussed below, these datatypes could be used in other XML-related standards as well.
Other specifications on which this one depends are listed in References (§K).
This specification defines some datatypes which depend on definitions in [XML] and [Namespaces in XML]; those definitions, and therefore the datatypes based on them, vary between version 1.0 ([XML 1.0], [Namespaces in XML 1.0]) and version 1.1 ([XML], [Namespaces in XML]) of those specifications. In any given use of this specification, the choice of the 1.0 or the 1.1 definition of those datatypes is ·implementation-defined·.
Conforming implementations of this specification may provide either the 1.1-based datatypes or the 1.0-based datatypes, or both. If both are supported, the choice of which datatypes to use in a particular assessment episode should be under user control.
This specification makes use of the EBNF notation used in the [XML] specification. Note that some constructs of the EBNF notation used here resemble the regular-expression syntax defined in this specification (Regular Expressions (§G)), but that they are not identical: there are differences. For a fuller description of the EBNF notation, see Section 6. Notation of the [XML] specification.
The [XML Schema Requirements] document spells out concrete requirements to be fulfilled by this specification, which state that the XML Schema Language must:
This specification defines datatypes that can be used in an XML Schema. These datatypes can be specified for element content that would be specified as #PCDATA and attribute values of various types in a DTD. It is the intention of this specification that it be usable outside of the context of XML Schemas for a wide range of other XML-related activities such as [XSL] and [RDF Schema].
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:
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:
This section describes the conceptual framework behind the datatype system defined in this specification. The framework has been influenced by the [ISO 11404] standard on language-independent datatypes as well as the datatypes for [SQL] and for programming languages such as Java.
The datatypes discussed in this specification are for the most part well known abstract concepts such as integer and date. It is not the place of this specification to thoroughly define these abstract concepts; many other publications provide excellent definitions. However, this specification will attempt to describe the abstract concepts well enough that they can be readily recognized and distinguished from other abstractions with which they may be confused.
Along with the ·lexical mapping· it is often useful to have an inverse which provides a standard ·lexical representation· for each value. Such a ·canonical mapping· is not required for schema processing, but is described herein for the benefit of users of this specification, and other specifications which might find it useful to reference these descriptions normatively. For some datatypes, notably QName and NOTATION, the mapping from lexical representations to values is context-dependent; for these types, no ·canonical mapping· is defined.
[Definition:] The value space of a datatype is the set of values for that datatype. Associated with each value space are selected operations and relations necessary to permit proper schema processing. Each value in the value space of a ·primitive· or ·ordinary· datatype is denoted by one or more character strings in its ·lexical space·, according to ·the lexical mapping·; ·special· datatypes, by contrast, may include "ineffable" values not mapped to by any lexical representation. (If the mapping is restricted during a derivation in such a way that a value has no denotation, that value is dropped from the value space.)
The value spaces of datatypes are abstractions, and are defined in Built-in Datatypes and Their Definitions (§3) to the extent needed to clarify them for readers. For example, in defining the numerical datatypes, we assume some general numerical concepts such as number and integer are known. In many cases we provide references to other documents providing more complete definitions.
The relations of identity and equality are required for each value space. An order relation is specified for some value spaces, but not all. A very few datatypes have other relations or operations prescribed for the purposes of this specification.
The identity relation is always defined. Every value space inherently has an identity relation. Two things are identical if and only if they are actually the same thing: i.e., if there is no way whatever to tell them apart.
In the identity relation defined herein, values from different ·primitive· datatypes' ·value spaces· are made artificially distinct if they might otherwise be considered identical. For example, there is a number two in the decimal datatype and a number two in the float datatype. In the identity relation defined herein, these two values are considered distinct. Other applications making use of these datatypes may choose to consider values such as these identical, but for the view of ·primitive· datatypes' ·value spaces· used herein, they are distinct.
WARNING: Care must be taken when identifying
values across distinct primitive datatypes. The
·literals· '0.1
' and '0.10000000009
' map
to the same value in float (neither 0.1 nor 0.10000000009 is in the value space, and
each literal is mapped to the
nearest value, namely 0.100000001490116119384765625), but map to
distinct values in decimal.
+2
', treated as a decimal,
'+2
', treated as an integer, and
'+2
', treated as a byte, all denote the
same value. They are not only equal but identical.Given a list A and a list B, A and B are the same list if they are the same sequence of atomic values. The necessary and sufficient conditions for this identity are that A and B have the same length and that the items of A are pairwise identical to the items of B.
Each ·primitive· datatype has prescribed an equality relation for its value space. The equality relation for most datatypes is the identity relation. In the few cases where it is not, equality has been carefully defined so that for most operations of interest to the datatype, if two values are equal and one is substituted for the other as an argument to any of the operations, the results will always also be equal.
On the other hand, equality need not cover the entire value space of the datatype (though it usually does). In particular, NaN is not equal to itself in the float and double datatypes.
This equality relation is used in conjunction with identity when making ·facet-based restrictions· by enumeration, when checking identity constraints (in the context of [XSD 1.1 Part 1: Structures]) and when checking value constraints. It is used in conjunction with order when making ·facet-based restrictions· involving order. The equality relation used in the evaluation of XPath expressions may differ. When processing XPath expressions as part of XML schema-validity assessment or otherwise testing membership in the ·value space· of a datatype whose derivation involves ·assertions·, equality (like all other relations) within those expressions is interpreted using the rules of XPath ([XPath 2.0]). All comparisons for "sameness" prescribed by this specification test for either equality or identity, not for identity alone.
In the equality relation defined herein, values from different primitive data spaces are made artificially unequal even if they might otherwise be considered equal. For example, there is a number two in the decimal datatype and a number two in the float datatype. In the equality relation defined herein, these two values are considered unequal. Other applications making use of these datatypes may choose to consider values such as these equal; nonetheless, in the equality relation defined herein, they are unequal.
Two lists A and B are equal if and only if they have the same length and their items are pairwise equal. A list of length one containing a value V1 and an atomic value V2 are equal if and only if V1 is equal to V2.
For the purposes of this specification, there is one equality relation for all values of all datatypes (the union of the various datatype's individual equalities, if one consider relations to be sets of ordered pairs). The equality relation is denoted by '=' and its negation by '≠', each used as a binary infix predicate: x = y and x ≠ y . On the other hand, identity relationships are always described in words.
For some datatypes, an order relation is prescribed for use in checking upper and lower bounds of the ·value space·. This order may be a partial order, which means that there may be values in the ·value space· which are neither equal, less-than, nor greater-than. Such value pairs are incomparable. In many cases, no order is prescribed; each pair of values is either equal or ·incomparable·. [Definition:] Two values that are neither equal, less-than, nor greater-than are incomparable. Two values that are not ·incomparable· are comparable.
The order relation is used in conjunction with equality when making ·facet-based restrictions· involving order. This is the only use of this order relation for schema processing. Of course, when processing XPath expressions as part of XML schema-validity assessment or otherwise testing membership in the ·value space· of a datatype whose derivation involves ·assertions·, order (like all other relations) within those expressions is interpreted using the rules of XPath ([XPath 2.0]).
In this specification, this less-than order relation is denoted by '<' (and its inverse by '>'), the weak order by '≤' (and its inverse by '≥'), and the resulting ·incomparable· relation by '<>', each used as a binary infix predicate: x < y , x ≤ y , x > y , x ≥ y , and x <> y .
For purposes of this specification, the value spaces of primitive datatypes are disjoint, even in cases where the abstractions they represent might be thought of as having values in common. In the order relations defined in this specification, values from different value spaces are ·incomparable·. For example, the numbers two and three are values in both the decimal datatype and the float datatype. In the order relation defined here, the two in the decimal datatype is not less than the three in the float datatype; the two values are incomparable. Other applications making use of these datatypes may choose to consider values such as these comparable.
[Definition:] The lexical mapping for a datatype is a prescribed relation which maps from the ·lexical space· of the datatype into its ·value space·.
[Definition:] The lexical space of a datatype is the prescribed set of strings which ·the lexical mapping· for that datatype maps to values of that datatype.
[Definition:] The members of the ·lexical space· are lexical representations of the values to which they are mapped.
[Definition:] A sequence of zero or more characters in the Universal Character Set (UCS) which may or may not prove upon inspection to be a member of the ·lexical space· of a given datatype and thus a ·lexical representation· of a given value in that datatype's ·value space·, is referred to as a literal. The term is used indifferently both for character sequences which are members of a particular ·lexical space· and for those which are not.
If a derivation introduces a ·pre-lexical· facet value (a new value for whiteSpace or an implementation-defined ·pre-lexical· facet), the corresponding ·pre-lexical· transformation of a character string, if indeed it changed that string, could prevent that string from ever having the ·lexical mapping· of the derived datatype applied to it. Character strings that a ·pre-lexical· transformation blocks in this way (i.e., they are not in the range of the ·pre-lexical· facet's transformation) are always dropped from the derived datatype's ·lexical space·.
Should a derivation be made using a derivation mechanism that removes ·lexical representations· from the·lexical space· to the extent that one or more values cease to have any ·lexical representation·, then those values are dropped from the ·value space·.
Conversely, should a derivation remove values then their ·lexical representations· are dropped from the ·lexical space· unless there is a facet value whose impact is defined to cause the otherwise-dropped ·lexical representation· to be mapped to another value instead.
For example, '100' and '1.0E2' are two different ·lexical representations· from the float datatype which both denote the same value. The datatype system defined in this specification provides mechanisms for schema designers to control the ·value space· and the corresponding set of acceptable ·lexical representations· of those values for a datatype.
While the datatypes defined in this specification often have a single ·lexical representation· for each value (i.e., each value in the datatype's ·value space· is denoted by a single ·representation· in its ·lexical space·), this is not always the case. The example in the previous section shows two ·lexical representations· from the float datatype which denote the same value.
[Definition:] The canonical mapping is a prescribed subset of the inverse of a ·lexical mapping· which is one-to-one and whose domain (where possible) is the entire range of the ·lexical mapping· (the ·value space·). Thus a ·canonical mapping· selects one ·lexical representation· for each value in the ·value space·.
[Definition:] The canonical representation of a value in the ·value space· of a datatype is the ·lexical representation· associated with that value by the datatype's ·canonical mapping·.
·Canonical mappings· are not available for datatypes whose ·lexical mappings· are context dependent (i.e., mappings for which the value of a ·lexical representation· depends on the context in which it occurs, or for which a character string may or may not be a valid ·lexical representation· similarly depending on its context)
It is useful to categorize the datatypes defined in this specification along various dimensions, defining terms which can be used to characterize datatypes and the Simple Type Definitions which define them.
First, we distinguish ·atomic·, ·list·, and ·union· datatypes.
[Definition:] An atomic value is an elementary value, not constructed from simpler values by any user-accessible means defined by this specification.
For example, a single token which ·matches· Nmtoken from [XML] is in the value space of the ·atomic· datatype NMTOKEN, while a sequence of such tokens is in the value space of the ·list· datatype NMTOKENS.
An ·atomic· datatype has a ·value space· consisting of a set of "atomic" or elementary values.
The ·lexical space· of an ·atomic· datatype is a set of ·literals· whose internal structure is specific to the datatype in question.
There is one ·special· ·atomic· datatype (anyAtomicType), and a number of ·primitive· ·atomic· datatypes which have anyAtomicType as their ·base type·. All other ·atomic· datatypes are ·derived· either from one of the ·primitive· ·atomic· datatypes or from another ·ordinary· ·atomic· datatype. No ·user-defined· datatype may have anyAtomicType as its ·base type·.
·List· datatypes are always ·constructed· from some other type; they are never ·primitive·. The ·value space· of a ·list· datatype is the set of finite-length sequences of zero or more ·atomic· values where each ·atomic· value is drawn from the ·value space· of the lists's ·item type· and has a ·lexical representation· containing no whitespace. The ·lexical space· of a ·list· datatype is a set of ·literals· each of which is a space-separated sequence of ·literals· of the ·item type·.
[Definition:] The ·atomic· or ·union· datatype that participates in the definition of a ·list· datatype is the item type of that ·list· datatype. If the ·item type· is a ·union·, each of its ·basic members· must be ·atomic·.
<simpleType name='sizes'> <list itemType='decimal'/> </simpleType>
<cerealSizes xsi:type='sizes'> 8 10.5 12 </cerealSizes>
A ·list· datatype can be ·constructed· from an ordinary or ·primitive· ·atomic· datatype whose ·lexical space· allows whitespace (such as string or anyURI) or a ·union· datatype any of whose {member type definitions}'s ·lexical space· allows space. Since ·list· items are separated at whitespace before the ·lexical representations· of the items are mapped to values, no whitespace will ever occur in the ·lexical representation· of a ·list· item, even when the item type would in principle allow it. For the same reason, when every possible ·lexical representation· of a given value in the ·value space· of the ·item type· includes whitespace, that value can never occur as an item in any value of the ·list· datatype.
<simpleType name='listOfString'> <list itemType='string'/> </simpleType>
<someElement xsi:type='listOfString'> this is not list item 1 this is not list item 2 this is not list item 3 </someElement>
For each of ·length·, ·maxLength· and ·minLength·, the length is measured in number of list items. The value of ·whiteSpace· is fixed to the value collapse.
For ·list· datatypes the ·lexical space· is composed of space-separated ·literals· of the ·item type·. Any ·pattern· specified when a new datatype is ·derived· from a ·list· datatype applies to the members of the ·list· datatype's ·lexical space·, not to the members of the ·lexical space· of the ·item type·. Similarly, enumerated values are compared to the entire ·list·, not to individual list items, and assertions apply to the entire ·list· too. Lists are identical if and only if they have the same length and their items are pairwise identical; they are equal if and only if they have the same length and their items are pairwise equal. And a list of length one whose item is an atomic value V1 is equal or identical to an atomic value V2 if and only if V1 is equal or identical to V2.
<xs:simpleType name='myList'> <xs:list itemType='xs:integer'/> </xs:simpleType> <xs:simpleType name='myRestrictedList'> <xs:restriction base='myList'> <xs:pattern value='123 (\d+\s)*456'/> </xs:restriction> </xs:simpleType> <someElement xsi:type='myRestrictedList'>123 456</someElement> <someElement xsi:type='myRestrictedList'>123 987 456</someElement> <someElement xsi:type='myRestrictedList'>123 987 567 456</someElement>
The ·canonical mapping· of a ·list· datatype maps each value onto the space-separated concatenation of the ·canonical representations· of all the items in the value (in order), using the ·canonical mapping· of the ·item type·.
Union types may be defined in either of two ways. When a union type is ·constructed· by ·union·, its ·value space·, ·lexical space·, and ·lexical mapping· are the "ordered unions" of the ·value spaces·, ·lexical spaces·, and ·lexical mappings· of its ·member types·.
It will be observed that the ·lexical mapping· of a union, so
defined, is not necessarily a function: a given ·literal· may map to
one value or to several values of different ·primitive· datatypes, and
it may be indeterminate which value is to be preferred in a particular
context. When the datatypes defined here are used in the context of
[XSD 1.1 Part 1: Structures], the xsi:type
attribute defined by that
specification in section xsi:type can be used to indicate
which value a ·literal· which is the content of an element should map
to. In other contexts, other rules (such as type coercion rules) may
be employed to determine which value is to be used.
When a union type is defined by ·restricting· another ·union·, its ·value space·, ·lexical space·, and ·lexical mapping· are subsets of the ·value spaces·, ·lexical spaces·, and ·lexical mappings· of its ·base type·.
·Union· datatypes are always ·constructed· from other datatypes; they are never ·primitive·. Currently, there are no ·built-in· ·union· datatypes.
<attributeGroup name="occurs"> <attribute name="minOccurs" type="nonNegativeInteger" use="optional" default="1"/> <attribute name="maxOccurs"use="optional" default="1"> <simpleType> <union> <simpleType> <restriction base='nonNegativeInteger'/> </simpleType> <simpleType> <restriction base='string'> <enumeration value='unbounded'/> </restriction> </simpleType> </union> </simpleType> </attribute> </attributeGroup>
Any number (zero or more) of ordinary or ·primitive· ·datatypes· can participate in a ·union· type.
[Definition:] The datatypes that participate in the definition of a ·union· datatype are known as the member types of that ·union· datatype.
[Definition:] The transitive membership of a ·union· is the set of its own ·member types·, and the ·member types· of its members, and so on. More formally, if U is a ·union·, then (a) its ·member types· are in the transitive membership of U, and (b) for any datatypes T1 and T2, if T1 is in the transitive membership of U and T2 is one of the ·member types· of T1, then T2 is also in the transitive membership of U.
The ·transitive membership· of a ·union· must not contain the ·union· itself, nor any datatype ·derived· or ·constructed· from the ·union·.
[Definition:] Those members of the ·transitive membership· of a ·union· datatype U which are themselves not ·union· datatypes are the basic members of U.
[Definition:] If a datatype M is in the ·transitive membership· of a ·union· datatype U, but not one of U's ·member types·, then a sequence of one or more ·union· datatypes necessarily exists, such that the first is one of the ·member types· of U, each is one of the ·member types· of its predecessor in the sequence, and M is one of the ·member types· of the last in the sequence. The ·union· datatypes in this sequence are said to intervene between M and U. When U and M are given by the context, the datatypes in the sequence are referred to as the intervening unions. When M is one of the ·member types· of U, the set of intervening unions is the empty set.
[Definition:] In a valid instance of any ·union·, the first of its members in order which accepts the instance as valid is the active member type. [Definition:] If the ·active member type· is itself a ·union·, one of its members will be its ·active member type·, and so on, until finally a ·basic (non-union) member· is reached. That ·basic member· is the active basic member of the union.
The order in which the ·member types· are specified in the
definition (that is, in the case of
datatypes defined in a schema document, the order of the
<simpleType> children of the <union> element, or the order
of the QNames in the memberTypes
attribute) is
significant. During validation, an element or attribute's value is
validated against the ·member types· in the order in which they appear
in the definition until a match is found. As noted above,
the evaluation order can be overridden with the use of
xsi:type.
<xs:element name='size'> <xs:simpleType> <xs:union> <xs:simpleType> <xs:restriction base='integer'/> </xs:simpleType> <xs:simpleType> <xs:restriction base='string'/> </xs:simpleType> </xs:union> </xs:simpleType> </xs:element>
<size>1</size> <size>large</size> <size xsi:type='xs:string'>1</size>
The ·canonical mapping· of a ·union· datatype maps each value onto the ·canonical representation· of that value obtained using the ·canonical mapping· of the first ·member type· in whose value space it lies.
Next, we distinguish ·special·, ·primitive·, and ·ordinary· (or ·constructed·) datatypes. Each datatype defined by or in accordance with this specification falls into exactly one of these categories.
For example, in this specification, float is a ·primitive· datatype based on a well-defined mathematical concept and not defined in terms of other datatypes, while integer is ·constructed· from the more general datatype decimal.
[Definition:] A datatype is defined by facet-based restriction of another datatype (its ·base type·), when values for zero or more ·constraining facets· are specified that serve to constrain its ·value space· and/or its ·lexical space· to a subset of those of the ·base type·. The ·base type· of a ·facet-based restriction· must be a ·primitive· or ·ordinary· datatype.
A ·list· datatype can be ·constructed· from another datatype (its ·item type·) by creating a ·value space· that consists of finite-length sequences of zero or more values of its ·item type·. Datatypes so ·constructed· have anySimpleType as their ·base type·. Note that since the ·value space· and ·lexical space· of any ·list· datatype are necessarily subsets of the ·value space· and ·lexical space· of anySimpleType, any datatype ·constructed· as a ·list· is a ·restriction· of its base type.
One datatype can be ·constructed· from one or more datatypes by unioning their ·lexical mappings· and, consequently, their ·value spaces· and ·lexical spaces·. Datatypes so ·constructed· also have anySimpleType as their ·base type·. Note that since the ·value space· and ·lexical space· of any ·union· datatype are necessarily subsets of the ·value space· and ·lexical space· of anySimpleType, any datatype ·constructed· as a ·union· is a ·restriction· of its base type.
Definition, derivation, restriction, and construction are conceptually distinct, although in practice they are frequently performed by the same mechanisms.
By 'definition' is meant the explicit identification of the relevant properties of a datatype, in particular its ·value space·, ·lexical space·, and ·lexical mapping·.
The properties of the ·special· and the standard ·primitive· datatypes are defined by this specification. A Simple Type Definition is present for each of these datatypes in every valid schema; it serves as a representation of the datatype, but by itself it does not capture all the relevant information and does not suffice (without knowledge of this specification) to define the datatype.
For all other datatypes, a Simple Type Definition does suffice. The properties of an ·ordinary· datatype can be inferred from the datatype's Simple Type Definition and the properties of the ·base type·, ·item type· if any, and ·member types· if any. All ·ordinary· datatypes can be defined in this way.
By 'derivation' is meant the relation of a datatype to its ·base type·, or to the ·base type· of its ·base type·, and so on.
Every datatype other than anySimpleType is associated with another datatype, its base type. Base types can be ·special·, ·primitive·, or ·ordinary·.
[Definition:] A datatype T is immediately derived from another datatype X if and only if X is the ·base type· of T.
A datatype must not be ·derived· from itself. That is, the base type relation must be acyclic.
It is a consequence of the above that every datatype other than anySimpleType is ·derived· from anySimpleType.
Since each datatype has exactly one ·base type·, and every datatype other than anySimpleType is ·derived· directly or indirectly from anySimpleType, it follows that the ·base type· relation arranges all simple types into a tree structure, which is conventionally referred to as the derivation hierarchy.
By 'restriction' is meant the definition of a datatype whose ·value space· and ·lexical space· are subsets of those of its ·base type·.
Note that all three forms of datatype ·construction· produce ·restrictions· of the ·base type·: ·facet-based restriction· does so by means of ·constraining facets·, while ·construction· by ·list· or ·union· does so because those ·constructions· take anySimpleType as the ·base type·. It follows that all datatypes are ·restrictions· of anySimpleType. This specification provides no means by which a datatype may be defined so as to have a larger ·lexical space· or ·value space· than its ·base type·.
By 'construction' is meant the creation of a datatype by defining it in terms of another.
[Definition:] All ·ordinary· datatypes are defined in terms of, or constructed from, other datatypes, either by ·restricting· the ·value space· or ·lexical space· of a ·base type· using zero or more ·constraining facets· or by specifying the new datatype as a ·list· of items of some ·item type·, or by defining it as a ·union· of some specified sequence of ·member types·. These three forms of ·construction· are often called "·facet-based restriction·", "·construction· by ·list·", and "·construction· by ·union·", respectively. Datatypes so constructed may be understood fully (for purposes of a type system) in terms of (a) the properties of the datatype(s) from which they are constructed, and (b) their Simple Type Definition. This distinguishes ·ordinary· datatypes from the ·special· and ·primitive· datatypes, which can be understood only in the light of documentation (namely, their descriptions elsewhere in this specification, or, for ·implementation-defined· ·primitives·, in the appropriate implementation-specific documentation). All ·ordinary· datatypes are ·constructed·, and all ·constructed· datatypes are ·ordinary·.
The ·built-in· datatypes are intended to be available automatically whenever this specification is implemented or used, whether by itself or embedded in a host language. In the language defined by [XSD 1.1 Part 1: Structures], the ·built-in· datatypes are automatically included in every valid schema. Other host languages should specify that all of the datatypes decribed here as built-ins are automatically available; they may specify that additional datatypes are also made available automatically.
The mechanism for making ·user-defined· datatypes available for use is not defined in this specification; if ·user-defined· datatypes are to be available, some such mechanism must be specified by the host language.
[Definition:] A datatype which is not available for use is said to be unknown.
Conceptually there is no difference between the ·ordinary· ·built-in· datatypes included in this specification and the ·user-defined· datatypes which will be created by individual schema designers. The ·built-in· ·constructed· datatypes are those which are believed to be so common that if they were not defined in this specification many schema designers would end up reinventing them. Furthermore, including these ·constructed· datatypes in this specification serves to demonstrate the mechanics and utility of the datatype generation facilities of this specification.
http://www.w3.org/2001/XMLSchema#int
http://www.w3.org/2001/XMLSchema#maxInclusive
.
') followed by the name of the facethttp://www.w3.org/2001/XMLSchema#int.maxInclusive
The ·built-in· datatypes defined by this specification are designed to be used with the XML Schema definition language as well as other XML specifications. To facilitate usage within the XML Schema definition language, the ·built-in· datatypes in this specification have the namespace name:
To facilitate usage in specifications other than the XML Schema definition language, such as those that do not want to know anything about aspects of the XML Schema definition language other than the datatypes, each ·built-in· datatype is also defined in the namespace whose URI is:
Each ·user-defined· datatype may also be associated with a target namespace. If it is constructed from a schema document, then its namespace is typically the target namespace of that schema document. (See XML Representation of Schemas in [XSD 1.1 Part 1: Structures].)
The two datatypes at the root of the hierarchy of simple types are anySimpleType and anyAtomicType.
The definition of anySimpleType is a special ·restriction· of anyType. The ·lexical space· of anySimpleType is the set of all sequences of Unicode characters, and its ·value space· includes all ·atomic values· and all finite-length lists of zero or more ·atomic values·.
For further details of anySimpleType and its representation as a Simple Type Definition, see Built-in Simple Type Definitions (§4.1.6).
The ·value space· of anySimpleType is the set of all ·atomic values· and of all finite-length lists of zero or more ·atomic values·.
The ·lexical space· of anySimpleType is the set of all finite-length sequences of zero or more characters (as defined in [XML]) that ·match· the Char production from [XML]. This is equivalent to the union of the ·lexical spaces· of all ·primitive· and all possible ·ordinary· datatypes.
It is ·implementation-defined· whether an implementation of this specification supports the Char production from [XML], or that from [XML 1.0], or both. See Dependencies on Other Specifications (§1.3).
The ·lexical mapping· of anySimpleType is the union
of the ·lexical mappings· of
all ·primitive· datatypes and all list datatypes.
It will be noted that this mapping is not a function: a given
·literal· may map to one value or to several values of different
·primitive· datatypes, and it may be indeterminate which value is to
be preferred in a particular context. When the datatypes defined here
are used in the context of [XSD 1.1 Part 1: Structures], the
xsi:type
attribute defined by that specification in section
xsi:type can be used
to indicate which value a ·literal· which is the content of an element
should map to. In other contexts, other rules (such as type coercion
rules) may be employed to determine which value is to be used.
When a new datatype is defined by ·facet-based restriction·, anySimpleType must not be used as the ·base type·. So no ·constraining facets· are directly applicable to anySimpleType.
[Definition:] anyAtomicType is a special ·restriction· of anySimpleType. The ·value· and ·lexical spaces· of anyAtomicType are the unions of the ·value· and ·lexical spaces· of all the ·primitive· datatypes, and anyAtomicType is their ·base type·.
For further details of anyAtomicType and its representation as a Simple Type Definition, see Built-in Simple Type Definitions (§4.1.6).
The ·value space· of anyAtomicType is the union of the ·value spaces· of all the ·primitive· datatypes defined here or supplied as ·implementation-defined· ·primitives·.
The ·lexical space· of anyAtomicType is the set of all finite-length sequences of zero or more characters (as defined in [XML]) that ·match· the Char production from [XML]. This is equivalent to the union of the ·lexical spaces· of all ·primitive· datatypes.
It is ·implementation-defined· whether an implementation of this specification supports the Char production from [XML], or that from [XML 1.0], or both. See Dependencies on Other Specifications (§1.3).
The ·lexical mapping· of anyAtomicType is the union
of the ·lexical mappings· of
all ·primitive· datatypes.
It will be noted that this mapping is not a function: a given
·literal· may map to one value or to several values of different
·primitive· datatypes, and it may be indeterminate which value is to
be preferred in a particular context. When the datatypes defined here
are used in the context of [XSD 1.1 Part 1: Structures], the
xsi:type
attribute defined by that specification in section
xsi:type can be used
to indicate which value a ·literal· which is the content of an element
should map to. In other contexts, other rules (such as type coercion
rules) may be employed to determine which value is to be used.
When a new datatype is defined by ·facet-based restriction·, anyAtomicType must not be used as the ·base type·. So no ·constraining facets· are directly applicable to anyAtomicType.
The ·primitive· datatypes defined by this specification are described below. For each datatype, the ·value space· is described; the ·lexical space· is defined using an extended Backus Naur Format grammar (and in most cases also a regular expression using the regular expression language of Regular Expressions (§G)); ·constraining facets· which apply to the datatype are listed; and any datatypes ·constructed· from this datatype are specified.
Conforming processors must support the ·primitive· datatypes defined in this specification; it is ·implementation-defined· whether they support others. ·Primitive· datatypes may be added by revisions to this specification.
[Definition:] The string datatype represents character strings in XML.
The ·value space· of string is the set of finite-length sequences of zero or more characters (as defined in [XML]) that ·match· the Char production from [XML]. A character is an atomic unit of communication; it is not further specified except to note that every character has a corresponding Universal Character Set (UCS) code point, which is an integer.
It is ·implementation-defined· whether an implementation of this specification supports the Char production from [XML], or that from [XML 1.0], or both. See Dependencies on Other Specifications (§1.3).
Equality for string is identity. No order is prescribed.
It is ·implementation-defined· whether an implementation of this specification supports the Char production from [XML], or that from [XML 1.0], or both. See Dependencies on Other Specifications (§1.3).
The ·lexical mapping· for string is ·stringLexicalMap·, and the ·canonical mapping· is ·stringCanonicalMap·; each is a subset of the identity function.
The string datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from string may also specify values for the following ·constraining facets·:
The string datatype has the following values for its ·fundamental facets·:
The following ·built-in· datatype is ·derived· from string
[Definition:] boolean represents the values of two-valued logic.
boolean has the ·value space· of two-valued logic: {true, false}.
The ·lexical mapping· for boolean is ·booleanLexicalMap·; the ·canonical mapping· is ·booleanCanonicalMap·.
The boolean datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
Datatypes derived by restriction from boolean may also specify values for the following ·constraining facets·:
The boolean datatype has the following values for its ·fundamental facets·:
[Definition:] decimal represents a subset of the real numbers, which can be represented by decimal numerals. The ·value space· of decimal is the set of numbers that can be obtained by dividing an integer by a non-negative power of ten, i.e., expressible as i / 10n where i and n are integers and n ≥ 0. Precision is not reflected in this value space; the number 2.0 is not distinct from the number 2.00. The order relation on decimal is the order relation on real numbers, restricted to this subset.
decimal
has
a lexical representation
consisting of a
non-empty finite-length
sequence of
decimal
digits (#x30–#x39) separated
by a period as a decimal indicator.
An optional leading sign is allowed.
If the sign is omitted,
"+"
is assumed. Leading and trailing zeroes are optional.
If the fractional part is zero, the period and following zero(es) can
be omitted.
For example:
'-1.23
',
'12678967.543233
', '+100000.00
',
'210
'.
(\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)
The mapping from lexical representations to values is the usual one for decimal numerals; it is given formally in ·decimalLexicalMap·.
The definition of the ·canonical representation· has the effect of prohibiting certain options from the Lexical Mapping (§3.3.3.1). Specifically, for integers, the decimal point and fractional part are prohibited. For other values, the preceding optional "+" sign is prohibited. The decimal point is required. In all cases, leading and trailing zeroes are prohibited subject to the following: there must be at least one digit to the right and to the left of the decimal point which may be a zero.
The mapping from values to ·canonical representations· is given formally in ·decimalCanonicalMap·.
The decimal datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
Datatypes derived by restriction from decimal may also specify values for the following ·constraining facets·:
The decimal datatype has the following values for its ·fundamental facets·:
The following ·built-in· datatype is ·derived· from decimal
[Definition:] The float datatype is patterned after the IEEE single-precision 32-bit floating point datatype [IEEE 754-2008]. Its value space is a subset of the rational numbers. Floating point numbers are often used to approximate arbitrary real numbers.
The ·value space· of float contains the non-zero numbers m × 2e , where m is an integer whose absolute value is less than 224, and e is an integer between −149 and 104, inclusive. In addition to these values, the ·value space· of float also contains the following ·special values·: positiveZero, negativeZero, positiveInfinity, negativeInfinity, and notANumber.
NaN
'. Accordingly, in English
text we generally use 'NaN' to refer to that value. Similarly,
we use 'INF' and '−INF' to refer to the two
values positiveInfinity and negativeInfinity,
and '0' and '−0' to refer to
positiveZero and negativeZero.NaN
').INF
', '+INF
',
'-INF
',
and 'NaN
'
(\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)([Ee](\+|-)?[0-9]+)?
|(\+|-)?INF|NaN
The float datatype is designed to implement for schema
processing the single-precision floating-point datatype of
[IEEE 754-2008]. That specification does not specify specific
·lexical representations·,
but does prescribe requirements on any ·lexical mapping·
used. Any ·lexical mapping·
that maps the ·lexical space· just described onto the
·value space·, is a function,
satisfies the requirements of
[IEEE 754-2008], and correctly handles the
mapping of the literals
'INF
', 'NaN
', etc., to the
·special values·,
satisfies the conformance requirements of this specification.
Since IEEE allows some variation in rounding of values, processors conforming to this specification may exhibit some variation in their ·lexical mappings·.
The ·lexical mapping· ·floatLexicalMap· is provided as an example of a simple algorithm that yields a conformant mapping, and that provides the most accurate rounding possible—and is thus useful for insuring inter-implementation reproducibility and inter-implementation round-tripping. The simple rounding algorithm used in ·floatLexicalMap· may be more efficiently implemented using the algorithms of [Clinger, WD (1990)].
The ·canonical mapping· ·floatCanonicalMap· is provided as an example of a mapping that does not produce unnecessarily long ·canonical representations·. Other algorithms which do not yield identical results for mapping from float values to character strings are permitted by [IEEE 754-2008].
The float datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
Datatypes derived by restriction from float may also specify values for the following ·constraining facets·:
The float datatype has the following values for its ·fundamental facets·:
[Definition:] The double datatype is patterned after the IEEE double-precision 64-bit floating point datatype [IEEE 754-2008]. Each floating point datatype has a value space that is a subset of the rational numbers. Floating point numbers are often used to approximate arbitrary real numbers.
The ·value space· of double contains the non-zero numbers m × 2e , where m is an integer whose absolute value is less than 253, and e is an integer between −1074 and 971, inclusive. In addition to these values, the ·value space· of double also contains the following ·special values·: positiveZero, negativeZero, positiveInfinity, negativeInfinity, and notANumber.
NaN
'. Accordingly, in English
text we generally use 'NaN' to refer to that value. Similarly,
we use 'INF' and '−INF' to refer to the two
values positiveInfinity and negativeInfinity,
and '0' and '−0' to refer to
positiveZero and negativeZero.NaN
').INF
', '+INF
',
'-INF
', and 'NaN
'
(\+|-)?([0-9]+(\.[0-9]*)?|\.[0-9]+)([Ee](\+|-)?[0-9]+)? |(\+|-)?INF|NaN
The double datatype is designed to implement for schema
processing the double-precision floating-point datatype of
[IEEE 754-2008]. That specification does not specify specific
·lexical representations·,
but does prescribe requirements on any ·lexical mapping·
used. Any ·lexical mapping·
that maps the ·lexical space· just described onto the
·value space·, is a function,
satisfies the requirements of
[IEEE 754-2008], and correctly handles the
mapping of the literals
'INF
', 'NaN
', etc., to the
·special values·,
satisfies the conformance requirements of this specification.
Since IEEE allows some variation in rounding of values, processors conforming to this specification may exhibit some variation in their ·lexical mappings·.
The ·lexical mapping· ·doubleLexicalMap· is provided as an example of a simple algorithm that yields a conformant mapping, and that provides the most accurate rounding possible—and is thus useful for insuring inter-implementation reproducibility and inter-implementation round-tripping. The simple rounding algorithm used in ·doubleLexicalMap· may be more efficiently implemented using the algorithms of [Clinger, WD (1990)].
The ·canonical mapping· ·doubleCanonicalMap· is provided as an example of a mapping that does not produce unnecessarily long ·canonical representations·. Other algorithms which do not yield identical results for mapping from float values to character strings are permitted by [IEEE 754-2008].
The double datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
Datatypes derived by restriction from double may also specify values for the following ·constraining facets·:
The double datatype has the following values for its ·fundamental facets·:
[Definition:] duration
is a datatype that represents
durations of time. The concept of duration being captured is
drawn from those of [ISO 8601], specifically
durations without fixed endpoints. For example,
"15 days" (whose most common lexical representation
in duration is "'P15D
'") is
a duration value; "15 days beginning 12 July
1995" and "15 days ending 12 July 1995" are
not duration
values. duration can provide addition and
subtraction operations between duration values and
between duration/dateTime value pairs,
and can be the result of subtracting dateTime
values. However, only addition to dateTime
is required for XML Schema processing and is
defined in
the function ·dateTimePlusDuration·.
Under the definition just given, two duration values are equal if and only if they are identical.
T
' ((duHourFrag duMinuteFrag? duSecondFrag?) |
(duMinuteFrag duSecondFrag?) |
duSecondFrag)Thus, a durationLexicalRep consists of one or more of a duYearFrag,
duMonthFrag, duDayFrag, duHourFrag,
duMinuteFrag, and/or duSecondFrag, in order, with letters
'P
' and 'T
' (and perhaps a '-
')
where appropriate.
matches only strings in which the fields occur in the proper order.
-?P[0-9]+Y?([0-9]+M)?([0-9]+D)?(T([0-9]+H)?([0-9]+M)?([0-9]+(\.[0-9]+)?S)?)?
.*[YMDHS].*
' matches only
strings in which at least one field occurs..*[^T]
' matches
only strings in which 'T
' is not the final character, so that
if 'T
' appears, something follows it. The first rule
ensures that what follows 'T
' will be an hour,
minute, or second field.-?P( ( ( [0-9]+Y([0-9]+M)?([0-9]+D)? | ([0-9]+M)([0-9]+D)? | ([0-9]+D) ) (T ( ([0-9]+H)([0-9]+M)?([0-9]+(\.[0-9]+)?S)? | ([0-9]+M)([0-9]+(\.[0-9]+)?S)? | ([0-9]+(\.[0-9]+)?S) ) )? ) | (T ( ([0-9]+H)([0-9]+M)?([0-9]+(\.[0-9]+)?S)? | ([0-9]+M)([0-9]+(\.[0-9]+)?S)? | ([0-9]+(\.[0-9]+)?S) ) ) )
The ·lexical mapping· for duration is ·durationMap·.
·The canonical mapping· for duration is ·durationCanonicalMap·.
The duration datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
Datatypes derived by restriction from duration may also specify values for the following ·constraining facets·:
The duration datatype has the following values for its ·fundamental facets·:
The following ·built-in· datatypes are ·derived· from duration
dateTime represents instants of time, optionally marked with a particular time zone offset. Values representing the same instant but having different time zone offsets are equal but not identical.
dateTime uses the date/timeSevenPropertyModel, with no properties except ·timezoneOffset· permitted to be absent. The ·timezoneOffset· property remains ·optional·.
Equality and order are as prescribed in The Seven-property Model (§D.2.1). dateTime values are ordered by their ·timeOnTimeline· value.
-
' monthFrag '-
' dayFrag 'T
' ((hourFrag ':
' minuteFrag ':
' secondFrag) |
endOfDayFrag) timezoneFrag? Constraint: Day-of-month Representations3
' or be '29
'
unless the value to
which it would map would satisfy the value constraint on
·day· values
("Constraint: Day-of-month Values") given above.-
', 'T
', and
':
', separate the various numerals.Z
' is an alternative representation of the time zone offset
'00:00
',
which is, of course, zero minutes from UTC.-?([1-9][0-9]{3,}|0[0-9]{3}) -(0[1-9]|1[0-2]) -(0[1-9]|[12][0-9]|3[01]) T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?)) (Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?Note that neither the dateTimeLexicalRep production nor this regular expression alone enforce the constraint on dateTimeLexicalRep given above.
The ·lexical mapping· for dateTime is ·dateTimeLexicalMap·. The ·canonical mapping· is ·dateTimeCanonicalMap·.
The dateTime datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The dateTime datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from dateTime may also specify values for the following ·constraining facets·:
The dateTime datatype has the following values for its ·fundamental facets·:
time represents instants of time that recur at the same point in each calendar day, or that occur in some arbitrary calendar day.
time uses the date/timeSevenPropertyModel, with ·year·, ·month·, and ·day· required to be absent. ·timezoneOffset· remains ·optional·.
Equality and order are as prescribed in The Seven-property Model (§D.2.1). time values (points in time in an "arbitrary" day) are ordered taking into account their ·timezoneOffset·.
A calendar (or "local time") day with a larger positive time zone offset begins earlier than the same calendar day with a smaller (or negative) time zone offset. Since the time zone offsets allowed spread over 28 hours, it is possible for the period denoted by a given calendar day with one time zone offset to be completely disjoint from the period denoted by the same calendar day with a different offset — the earlier day ends before the later one starts. The moments in time represented by a single calendar day are spread over a 52-hour interval, from the beginning of the day in the +14:00 time zone offset to the end of that day in the −14:00 time zone offset.
05:00:00-03:00
' and '10:00:00+02:00
',
now denote equal though distinct values
(because they identify the same points on the time line);
others,
such as '23:00:00-03:00
' and '02:00:00Z
',
now denote unequal values (23:00:00−03:00 > 02:00:00Z
because 23:00:00−03:00 on any given day is equal to
02:00:00Z on the next day).
Note that neither the timeLexicalRep production nor this regular expression alone enforce the constraint on timeLexicalRep given above.
(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?|(24:00:00(\.0+)?))(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?
The ·lexical mapping· for time is ·timeLexicalMap·; the ·canonical mapping· is ·timeCanonicalMap·.
00:00:00
' and
'24:00:00
' to the same value, namely midnight
(·hour· = 0 ,
·minute· = 0 ,
·second· = 0).The time datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The time datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from time may also specify values for the following ·constraining facets·:
The time datatype has the following values for its ·fundamental facets·:
[Definition:] date represents top-open intervals of exactly one day in length on the timelines of dateTime, beginning on the beginning moment of each day, up to but not including the beginning moment of the next day). For non-timezoned values, the top-open intervals disjointly cover the non-timezoned timeline, one per day. For timezoned values, the intervals begin at every minute and therefore overlap.
date uses the date/timeSevenPropertyModel, with ·hour·, ·minute·, and ·second· required to be absent. ·timezoneOffset· remains ·optional·.
Equality and order are as prescribed in The Seven-property Model (§D.2.1).
-
' monthFrag '-
' dayFrag timezoneFrag? Constraint: Day-of-month Representations3
' or be '29
'
unless the value to
which it would map would satisfy the value constraint on
·day· values
("Constraint: Day-of-month Values") given above.Note that neither the dateLexicalRep production nor this regular expression alone enforce the constraint on dateLexicalRep given above.
-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?
The ·lexical mapping· for date is ·dateLexicalMap·. The ·canonical mapping· is ·dateCanonicalMap·.
The date datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The date datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from date may also specify values for the following ·constraining facets·:
The date datatype has the following values for its ·fundamental facets·:
gYearMonth represents specific whole Gregorian months in specific Gregorian years.
gYearMonth uses the date/timeSevenPropertyModel, with ·day·, ·hour·, ·minute·, and ·second· required to be absent. ·timezoneOffset· remains ·optional·.
Equality and order are as prescribed in The Seven-property Model (§D.2.1).
-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?
The ·lexical mapping· for gYearMonth is ·gYearMonthLexicalMap·. The ·canonical mapping· is ·gYearMonthCanonicalMap·.
The gYearMonth datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The gYearMonth datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from gYearMonth may also specify values for the following ·constraining facets·:
The gYearMonth datatype has the following values for its ·fundamental facets·:
gYear represents Gregorian calendar years.
gYear uses the date/timeSevenPropertyModel, with ·month·, ·day·, ·hour·, ·minute·, and ·second· required to be absent. ·timezoneOffset· remains ·optional·.
Equality and order are as prescribed in The Seven-property Model (§D.2.1).
-?([1-9][0-9]{3,}|0[0-9]{3})(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?
The ·lexical mapping· for gYear is ·gYearLexicalMap·. The ·canonical mapping· is ·gYearCanonicalMap·.
The gYear datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The gYear datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from gYear may also specify values for the following ·constraining facets·:
The gYear datatype has the following values for its ·fundamental facets·:
gMonthDay represents whole calendar days that recur at the same point in each calendar year, or that occur in some arbitrary calendar year. (Obviously, days beyond 28 cannot occur in all Februaries; 29 is nonetheless permitted.)
This datatype can be used, for example, to record birthdays; an instance of the datatype could be used to say that someone's birthday occurs on the 14th of September every year.
gMonthDay uses the date/timeSevenPropertyModel, with ·year·, ·hour·, ·minute·, and ·second· required to be absent. ·timezoneOffset· remains ·optional·.
Equality and order are as prescribed in The Seven-property Model (§D.2.1).
--
' monthFrag '-
' dayFrag timezoneFrag? Constraint: Day-of-month Representations3
' or be '29
'
unless the value to
which it would map would satisfy the value constraint on
·day· values
("Constraint: Day-of-month Values") given above.Note that neither the gMonthDayLexicalRep production nor this regular expression alone enforce the constraint on gMonthDayLexicalRep given above.
--(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?
The ·lexical mapping· for gMonthDay is ·gMonthDayLexicalMap·. The ·canonical mapping· is ·gMonthDayCanonicalMap·.
The gMonthDay datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The gMonthDay datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from gMonthDay may also specify values for the following ·constraining facets·:
The gMonthDay datatype has the following values for its ·fundamental facets·:
[Definition:] gDay represents whole days within an arbitrary month—days that recur at the same point in each (Gregorian) month. This datatype is used to represent a specific day of the month. To indicate, for example, that an employee gets a paycheck on the 15th of each month. (Obviously, days beyond 28 cannot occur in all months; they are nonetheless permitted, up to 31.)
gDay uses the date/timeSevenPropertyModel, with ·year·, ·month·, ·hour·, ·minute·, and ·second· required to be absent. ·timezoneOffset· remains ·optional· and ·day· must be between 1 and 31 inclusive.
Equality and order are as prescribed in The Seven-property Model (§D.2.1). Since gDay values (days) are ordered by their first moments, it is possible for apparent anomalies to appear in the order when ·timezoneOffset· values differ by at least 24 hours. (It is possible for ·timezoneOffset· values to differ by up to 28 hours.)
---(0[1-9]|[12][0-9]|3[01])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?
The ·lexical mapping· for gDay is ·gDayLexicalMap·. The ·canonical mapping· is ·gDayCanonicalMap·.
The gDay datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The gDay datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from gDay may also specify values for the following ·constraining facets·:
The gDay datatype has the following values for its ·fundamental facets·:
gMonth represents whole (Gregorian) months within an arbitrary year—months that recur at the same point in each year. It might be used, for example, to say what month annual Thanksgiving celebrations fall in different countries (--11 in the United States, --10 in Canada, and possibly other months in other countries).
gMonth uses the date/timeSevenPropertyModel, with ·year·, ·day·, ·hour·, ·minute·, and ·second· required to be absent. ·timezoneOffset· remains ·optional·.
Equality and order are as prescribed in The Seven-property Model (§D.2.1).
--(0[1-9]|1[0-2])(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))?
The ·lexical mapping· for gMonth is ·gMonthLexicalMap·. The ·canonical mapping· is ·gMonthCanonicalMap·.
The gMonth datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The gMonth datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from gMonth may also specify values for the following ·constraining facets·:
The gMonth datatype has the following values for its ·fundamental facets·:
[Definition:] hexBinary represents arbitrary hex-encoded binary data.
The ·value space· of hexBinary is the set of finite-length sequences of zero or more binary octets. The length of a value is the number of octets.
hexBinary's ·lexical space·
consists of strings of hex (hexadecimal) digits, two consecutive digits
representing each octet in the corresponding value (treating the octet
as the binary representation of a number between 0 and 255). For
example, '0FB7
' is a ·lexical representation· of the
two-octet value 00001111 10110111.
The set recognized by hexBinary is the same as that recognized by the regular
expression '([0-9a-fA-F]{2})*
'.
The ·lexical mapping· of hexBinary is ·hexBinaryMap·.
The ·canonical mapping· of hexBinary is given formally in ·hexBinaryCanonical·.
The hexBinary datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
Datatypes derived by restriction from hexBinary may also specify values for the following ·constraining facets·:
The hexBinary datatype has the following values for its ·fundamental facets·:
[Definition:] base64Binary represents arbitrary Base64-encoded binary data. For base64Binary data the entire binary stream is encoded using the Base64 Encoding defined in [RFC 3548], which is derived from the encoding described in [RFC 2045].
The ·value space· of base64Binary is the set of finite-length sequences of zero or more binary octets. The length of a value is the number of octets.
The ·lexical representations· of
base64Binary
values are limited to the 65 characters of the Base64 Alphabet defined in
[RFC 3548],
i.e., a-z
, A-Z
,
0-9
, the plus sign (+), the forward slash (/) and the
equal sign (=), together with
the space character
(#x20). No other characters are allowed.
For compatibility with older mail gateways, [RFC 2045] suggests that Base64 data should have lines limited to at most 76 characters in length. This line-length limitation is not required by [RFC 3548] and is not mandated in the ·lexical representations· of base64Binary data. It must not be enforced by XML Schema processors.
The ·lexical space· of base64Binary is the set of literals which ·match· the base64Binaryproduction.
Note that each '
((([A-Za-z0-9+/] ?){4})*(([A-Za-z0-9+/] ?){3}[A-Za-z0-9+/]|([A-Za-z0-9+/] ?){2}[AEIMQUYcgkosw048] ?=|[A-Za-z0-9+/] ?[AQgw] ?= ?=))?
?
' except the last is preceded by a
single space character.Note that this grammar requires the number of non-whitespace characters in the ·lexical representation· to be a multiple of four, and for equals signs to appear only at the end of the ·lexical representation·; literals which do not meet these constraints are not legal ·lexical representations· of base64Binary.
The ·lexical mapping· for base64Binary is as given in [RFC 2045] and [RFC 3548].
The canonical ·lexical representation· of a base64Binary data value is the Base64 encoding of the value which matches the Canonical-base64Binary production in the following grammar:
That is, the ·canonical representation· of a base64Binary value is the ·lexical representation· which maps to that value and contains no whitespace. The ·canonical mapping· for base64Binary is thus the encoding algorithm for Base64 data given in [RFC 2045] and [RFC 3548], with the proviso that no characters except those in the Base64 Alphabet are to be written out.
The length of a base64Binary value may be calculated from the ·lexical representation· by removing whitespace and padding characters and performing the calculation shown in the pseudo-code below:
lex2 := killwhitespace(lexform)
-- remove whitespace characters
lex3 := strip_equals(lex2)
-- strip padding characters at end
length := floor (length(lex3) * 3 / 4)
-- calculate length
Note on encoding: [RFC 2045] and [RFC 3548] explicitly reference US-ASCII encoding. However, decoding of base64Binary data in an XML entity is to be performed on the Unicode characters obtained after character encoding processing as specified by [XML].
The base64Binary datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
Datatypes derived by restriction from base64Binary may also specify values for the following ·constraining facets·:
The base64Binary datatype has the following values for its ·fundamental facets·:
[Definition:] anyURI represents an Internationalized Resource Identifier Reference (IRI). An anyURI value can be absolute or relative, and may have an optional fragment identifier (i.e., it may be an IRI Reference). This type should be used when the value fulfills the role of an IRI, as defined in [RFC 3987] or its successor(s) in the IETF Standards Track.
The value space of anyURI is the set of finite-length sequences of zero or more characters (as defined in [XML]) that ·match· the Char production from [XML].
The ·lexical space· of anyURI is the set of finite-length sequences of zero or more characters (as defined in [XML]) that ·match· the Char production from [XML].
%20
').The ·lexical mapping· for anyURI is the identity mapping.
The anyURI datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
Datatypes derived by restriction from anyURI may also specify values for the following ·constraining facets·:
The anyURI datatype has the following values for its ·fundamental facets·:
[Definition:] QName represents XML qualified names. The ·value space· of QName is the set of tuples {namespace name, local part}, where namespace name is an anyURI and local part is an NCName. The ·lexical space· of QName is the set of strings that ·match· the QName production of [Namespaces in XML].
It is ·implementation-defined· whether an implementation of this specification supports the QName production from [Namespaces in XML], or that from [Namespaces in XML 1.0], or both. See Dependencies on Other Specifications (§1.3).
The mapping from lexical space to value space for a particular QName ·literal· depends on the namespace bindings in scope where the literal occurs.
When QNames appear in an XML context, the bindings to be used in the ·lexical mapping· are those in the [in-scope namespaces] property of the relevant element. When this datatype is used in a non-XML host language, the host language must specify what namespace bindings are to be used.
The host language, whether XML-based or otherwise, may specify whether unqualified names are bound to the default namespace (if any) or not; the host language may also place this under user control. If the host language does not specify otherwise, unqualified names are bound to the default namespace.
The QName datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
Datatypes derived by restriction from QName may also specify values for the following ·constraining facets·:
The QName datatype has the following values for its ·fundamental facets·:
[Definition:] NOTATION represents the NOTATION attribute type from [XML]. The ·value space· of NOTATION is the set of QNames of notations declared in the current schema. The ·lexical space· of NOTATION is the set of all names of notations declared in the current schema (in the form of QNames).
The lexical mapping rules for NOTATION are as given for QName in QName (§3.3.18).
For compatibility (see Terminology (§1.6)) NOTATION should be used only on attributes and should only be used in schemas with no target namespace.
The NOTATION datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
Datatypes derived by restriction from NOTATION may also specify values for the following ·constraining facets·:
The NOTATION datatype has the following values for its ·fundamental facets·:
The use of ·length·, ·minLength· and ·maxLength· on NOTATION or datatypes ·derived· from NOTATION is deprecated. Future versions of this specification may remove these facets for this datatype.
This section gives conceptual definitions for all ·built-in· ·ordinary· datatypes defined by this specification. The XML representation used to define ·ordinary· datatypes (whether ·built-in· or ·user-defined·) is given in XML Representation of Simple Type Definition Schema Components (§4.1.2) and the complete definitions of the ·built-in· ·ordinary· datatypes are provided in the appendix Schema for Schema Documents (Datatypes) (normative) (§A).
[Definition:] normalizedString represents white space normalized strings. The ·value space· of normalizedString is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters. The ·lexical space· of normalizedString is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters. The ·base type· of normalizedString is string.
The normalizedString datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from normalizedString may also specify values for the following ·constraining facets·:
The normalizedString datatype has the following values for its ·fundamental facets·:
[Definition:] token represents tokenized strings. The ·value space· of token is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters, that have no leading or trailing spaces (#x20) and that have no internal sequences of two or more spaces. The ·lexical space· of token is the set of strings that do not contain the carriage return (#xD), line feed (#xA) nor tab (#x9) characters, that have no leading or trailing spaces (#x20) and that have no internal sequences of two or more spaces. The ·base type· of token is normalizedString.
The token datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from token may also specify values for the following ·constraining facets·:
The token datatype has the following values for its ·fundamental facets·:
This is the set of strings accepted by the grammar given in [RFC 3066], which is now obsolete; the current specification of language codes is more restrictive. The ·base type· of language is token.
[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*
MN
' and
'mn
' (for
Mongolian)
therefore correspond to distinct values and
have distinct canonical forms. Users of this specification should be
aware of this fact, the consequence of which is that the
case-insensitive treatment of language values prescribed by
[BCP 47]
does not follow from the definition of
this datatype given here; applications which require
case-insensitivity
should make appropriate adjustments.xml:lang
defined by
[XML] is one example; there, the empty string
overrides a value which would otherwise be inherited, but
without specifying a new value.xml:lang
as having a type which is a union
of language and an anonymous type whose
only value is the empty string:<xs:attribute name="lang"> <xs:annotation> <xs:documentation> See RFC 3066 at http://www.ietf.org/rfc/rfc3066.txt and the IANA registry at http://www.iana.org/assignments/lang-tag-apps.htm for further information. The union allows for the 'un-declaration' of xml:lang with the empty string. </xs:documentation> </xs:annotation> <xs:simpleType> <xs:union memberTypes="xs:language"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value=""/> </xs:restriction> </xs:simpleType> </xs:union> </xs:simpleType> </xs:attribute>
The language datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from language may also specify values for the following ·constraining facets·:
The language datatype has the following values for its ·fundamental facets·:
[Definition:] NMTOKEN represents the NMTOKEN attribute type from [XML]. The ·value space· of NMTOKEN is the set of tokens that ·match· the Nmtoken production in [XML]. The ·lexical space· of NMTOKEN is the set of strings that ·match· the Nmtoken production in [XML]. The ·base type· of NMTOKEN is token.
It is ·implementation-defined· whether an implementation of this specification supports the NMTOKEN production from [XML], or that from [XML 1.0], or both. See Dependencies on Other Specifications (§1.3).
For compatibility (see Terminology (§1.6) NMTOKEN should be used only on attributes.
The NMTOKEN datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from NMTOKEN may also specify values for the following ·constraining facets·:
The NMTOKEN datatype has the following values for its ·fundamental facets·:
[Definition:] NMTOKENS
represents the NMTOKENS attribute
type from [XML]. The ·value space·
of NMTOKENS is the set of finite, non-zero-length sequences of
·NMTOKEN·s. The ·lexical space·
of NMTOKENS is the set of space-separated lists of tokens,
of which each token is in the ·lexical space· of
NMTOKEN. The ·item type· of
NMTOKENS is NMTOKEN.
NMTOKENS is derived
from ·anySimpleType
· in two steps: an anonymous list type
is defined, whose ·item type· is NMTOKEN; this is
the ·base type· of NMTOKENS, which restricts
its value space to lists with at least one item.
For compatibility (see Terminology (§1.6)) NMTOKENS should be used only on attributes.
The NMTOKENS datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from NMTOKENS may also specify values for the following ·constraining facets·:
The NMTOKENS datatype has the following values for its ·fundamental facets·:
[Definition:] Name represents XML Names. The ·value space· of Name is the set of all strings which ·match· the Name production of [XML]. The ·lexical space· of Name is the set of all strings which ·match· the Name production of [XML]. The ·base type· of Name is token.
It is ·implementation-defined· whether an implementation of this specification supports the Name production from [XML], or that from [XML 1.0], or both. See Dependencies on Other Specifications (§1.3).
The Name datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from Name may also specify values for the following ·constraining facets·:
The Name datatype has the following values for its ·fundamental facets·:
[Definition:] NCName represents XML "non-colonized" Names. The ·value space· of NCName is the set of all strings which ·match· the NCName production of [Namespaces in XML]. The ·lexical space· of NCName is the set of all strings which ·match· the NCName production of [Namespaces in XML]. The ·base type· of NCName is Name.
It is ·implementation-defined· whether an implementation of this specification supports the NCName production from [Namespaces in XML], or that from [Namespaces in XML 1.0], or both. See Dependencies on Other Specifications (§1.3).
The NCName datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from NCName may also specify values for the following ·constraining facets·:
The NCName datatype has the following values for its ·fundamental facets·:
[Definition:] ID represents the ID attribute type from [XML]. The ·value space· of ID is the set of all strings that ·match· the NCName production in [Namespaces in XML]. The ·lexical space· of ID is the set of all strings that ·match· the NCName production in [Namespaces in XML]. The ·base type· of ID is NCName.
For compatibility (see Terminology (§1.6)), ID should be used only on attributes.
The ID datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from ID may also specify values for the following ·constraining facets·:
The ID datatype has the following values for its ·fundamental facets·:
[Definition:] IDREF represents the IDREF attribute type from [XML]. The ·value space· of IDREF is the set of all strings that ·match· the NCName production in [Namespaces in XML]. The ·lexical space· of IDREF is the set of strings that ·match· the NCName production in [Namespaces in XML]. The ·base type· of IDREF is NCName.
For compatibility (see Terminology (§1.6)) this datatype should be used only on attributes.
The IDREF datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from IDREF may also specify values for the following ·constraining facets·:
The IDREF datatype has the following values for its ·fundamental facets·:
[Definition:]
IDREFS represents the
IDREFS attribute type from
[XML]. The ·value space· of
IDREFS is the set of finite, non-zero-length sequences of
IDREFs.
The ·lexical space· of IDREFS is the
set of space-separated lists of tokens, of which each token is in the
·lexical space· of IDREF.
The ·item type· of IDREFS
is IDREF.
IDREFS is derived
from ·anySimpleType
· in two steps: an anonymous list type
is defined, whose ·item type· is IDREF; this is
the ·base type· of IDREFS, which restricts
its value space to lists with at least one item.
For compatibility (see Terminology (§1.6)) IDREFS should be used only on attributes.
The IDREFS datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from IDREFS may also specify values for the following ·constraining facets·:
The IDREFS datatype has the following values for its ·fundamental facets·:
[Definition:] ENTITY represents the ENTITY attribute type from [XML]. The ·value space· of ENTITY is the set of all strings that ·match· the NCName production in [Namespaces in XML] and have been declared as an unparsed entity in a document type definition. The ·lexical space· of ENTITY is the set of all strings that ·match· the NCName production in [Namespaces in XML]. The ·base type· of ENTITY is NCName.
For compatibility (see Terminology (§1.6)) ENTITY should be used only on attributes.
The ENTITY datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from ENTITY may also specify values for the following ·constraining facets·:
The ENTITY datatype has the following values for its ·fundamental facets·:
[Definition:] ENTITIES
represents the ENTITIES attribute
type from [XML]. The ·value space·
of ENTITIES is the set of finite, non-zero-length sequences of
·ENTITY· values that have been declared as
unparsed entities
in a document type definition.
The ·lexical space· of ENTITIES is the
set of space-separated lists of tokens, of which each token is in the
·lexical space· of ENTITY.
The ·item type· of ENTITIES is
ENTITY.
ENTITIES is derived
from ·anySimpleType
· in two steps: an anonymous list type
is defined, whose ·item type· is ENTITY; this is
the ·base type· of ENTITIES, which restricts
its value space to lists with at least one item.
For compatibility (see Terminology (§1.6)) ENTITIES should be used only on attributes.
The ENTITIES datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from ENTITIES may also specify values for the following ·constraining facets·:
The ENTITIES datatype has the following values for its ·fundamental facets·:
[Definition:] integer is ·derived· from decimal by fixing the value of ·fractionDigits· to be 0 and disallowing the trailing decimal point. This results in the standard mathematical concept of the integer numbers. The ·value space· of integer is the infinite set {...,-2,-1,0,1,2,...}. The ·base type· of integer is decimal.
integer has a lexical representation consisting of a finite-length sequence of one or more decimal digits (#x30-#x39) with an optional leading sign. If the sign is omitted, "+" is assumed. For example: -1, 0, 12678967543233, +100000.
The ·canonical representation· for integer is defined by prohibiting certain options from the Lexical representation (§3.4.13.1). Specifically, the preceding optional "+" sign is prohibited and leading zeroes are prohibited.
The integer datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The integer datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from integer may also specify values for the following ·constraining facets·:
The integer datatype has the following values for its ·fundamental facets·:
The following ·built-in· datatypes are ·derived· from integer
[Definition:] nonPositiveInteger is ·derived· from integer by setting the value of ·maxInclusive· to be 0. This results in the standard mathematical concept of the non-positive integers. The ·value space· of nonPositiveInteger is the infinite set {...,-2,-1,0}. The ·base type· of nonPositiveInteger is integer.
nonPositiveInteger
has a lexical representation consisting of
an optional preceding sign
followed by a non-empty
finite-length sequence of decimal digits (#x30-#x39).
The sign may be "+" or may be omitted only for
lexical forms denoting zero; in all other lexical forms, the negative
sign ('-
') must be present.
For example: -1, 0, -12678967543233, -100000.
The ·canonical representation· for nonPositiveInteger is defined by prohibiting certain options from the Lexical representation (§3.4.14.1). In the canonical form for zero, the sign must be omitted. Leading zeroes are prohibited.
The nonPositiveInteger datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The nonPositiveInteger datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from nonPositiveInteger may also specify values for the following ·constraining facets·:
The nonPositiveInteger datatype has the following values for its ·fundamental facets·:
The following ·built-in· datatype is ·derived· from nonPositiveInteger
[Definition:] negativeInteger is ·derived· from nonPositiveInteger by setting the value of ·maxInclusive· to be -1. This results in the standard mathematical concept of the negative integers. The ·value space· of negativeInteger is the infinite set {...,-2,-1}. The ·base type· of negativeInteger is nonPositiveInteger.
negativeInteger
has a lexical representation consisting
of a negative sign ('-
') followed by a non-empty finite-length sequence of
decimal digits (#x30-#x39),
at least one of which must be a digit other than '0
'.
For example: -1, -12678967543233,
-100000.
The ·canonical representation· for negativeInteger is defined by prohibiting certain options from the Lexical representation (§3.4.15.1). Specifically, leading zeroes are prohibited.
The negativeInteger datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The negativeInteger datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from negativeInteger may also specify values for the following ·constraining facets·:
The negativeInteger datatype has the following values for its ·fundamental facets·:
[Definition:] long is ·derived· from integer by setting the value of ·maxInclusive· to be 9223372036854775807 and ·minInclusive· to be -9223372036854775808. The ·base type· of long is integer.
long has a lexical representation consisting of an optional sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39). If the sign is omitted, "+" is assumed. For example: -1, 0, 12678967543233, +100000.
The ·canonical representation· for long is defined by prohibiting certain options from the Lexical Representation (§3.4.16.1). Specifically, the the optional "+" sign is prohibited and leading zeroes are prohibited.
The long datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The long datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from long may also specify values for the following ·constraining facets·:
The long datatype has the following values for its ·fundamental facets·:
[Definition:] int is ·derived· from long by setting the value of ·maxInclusive· to be 2147483647 and ·minInclusive· to be -2147483648. The ·base type· of int is long.
int has a lexical representation consisting of an optional sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39). If the sign is omitted, "+" is assumed. For example: -1, 0, 126789675, +100000.
The ·canonical representation· for int is defined by prohibiting certain options from the Lexical Representation (§3.4.17.1). Specifically, the the optional "+" sign is prohibited and leading zeroes are prohibited.
The int datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The int datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from int may also specify values for the following ·constraining facets·:
The int datatype has the following values for its ·fundamental facets·:
[Definition:] short is ·derived· from int by setting the value of ·maxInclusive· to be 32767 and ·minInclusive· to be -32768. The ·base type· of short is int.
short has a lexical representation consisting of an optional sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39). If the sign is omitted, "+" is assumed. For example: -1, 0, 12678, +10000.
The ·canonical representation· for short is defined by prohibiting certain options from the Lexical representation (§3.4.18.1). Specifically, the the optional "+" sign is prohibited and leading zeroes are prohibited.
The short datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The short datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from short may also specify values for the following ·constraining facets·:
The short datatype has the following values for its ·fundamental facets·:
[Definition:] byte is ·derived· from short by setting the value of ·maxInclusive· to be 127 and ·minInclusive· to be -128. The ·base type· of byte is short.
byte has a lexical representation consisting of an optional sign followed by a non-empty finite-length sequence of decimal digits (#x30-#x39). If the sign is omitted, "+" is assumed. For example: -1, 0, 126, +100.
The ·canonical representation· for byte is defined by prohibiting certain options from the Lexical representation (§3.4.19.1). Specifically, the the optional "+" sign is prohibited and leading zeroes are prohibited.
The byte datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The byte datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from byte may also specify values for the following ·constraining facets·:
The byte datatype has the following values for its ·fundamental facets·:
[Definition:] nonNegativeInteger is ·derived· from integer by setting the value of ·minInclusive· to be 0. This results in the standard mathematical concept of the non-negative integers. The ·value space· of nonNegativeInteger is the infinite set {0,1,2,...}. The ·base type· of nonNegativeInteger is integer.
nonNegativeInteger
has a lexical representation consisting of
an optional sign followed by a non-empty finite-length
sequence of decimal digits (#x30-#x39). If the sign is omitted,
the positive sign ('+
') is assumed.
If the sign is present, it must be "+" except for lexical forms
denoting zero, which may be preceded by a positive ('+
') or a negative ('-
') sign.
For example:
1, 0, 12678967543233, +100000.
The ·canonical representation· for nonNegativeInteger is defined by prohibiting certain options from the Lexical representation (§3.4.20.1). Specifically, the the optional "+" sign is prohibited and leading zeroes are prohibited.
The nonNegativeInteger datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The nonNegativeInteger datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from nonNegativeInteger may also specify values for the following ·constraining facets·:
The nonNegativeInteger datatype has the following values for its ·fundamental facets·:
The following ·built-in· datatypes are ·derived· from nonNegativeInteger
[Definition:] unsignedLong is ·derived· from nonNegativeInteger by setting the value of ·maxInclusive· to be 18446744073709551615. The ·base type· of unsignedLong is nonNegativeInteger.
unsignedLong
has a lexical representation consisting of
an optional sign followed by a
non-empty
finite-length sequence of decimal digits (#x30-#x39).
If the sign is omitted, the positive sign
('+
') is assumed. If the sign is present, it
must
be
'+
' except for lexical forms denoting zero, which may
be preceded by a positive ('+
') or a negative
('-
') sign. For example: 0, 12678967543233,
100000.
The ·canonical representation· for unsignedLong is defined by prohibiting certain options from the Lexical representation (§3.4.21.1). Specifically, leading zeroes are prohibited.
The unsignedLong datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The unsignedLong datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from unsignedLong may also specify values for the following ·constraining facets·:
The unsignedLong datatype has the following values for its ·fundamental facets·:
The following ·built-in· datatype is ·derived· from unsignedLong
[Definition:] unsignedInt is ·derived· from unsignedLong by setting the value of ·maxInclusive· to be 4294967295. The ·base type· of unsignedInt is unsignedLong.
unsignedInt
has a lexical representation consisting
of an optional sign followed by a
non-empty
finite-length sequence of decimal digits (#x30-#x39).
If the sign is omitted, the positive sign
('+
') is assumed. If the sign is present, it
must
be
'+
' except for lexical forms denoting zero, which may
be preceded by a positive ('+
') or a negative
('-
') sign. For example: 0,
1267896754, 100000.
The ·canonical representation· for unsignedInt is defined by prohibiting certain options from the Lexical representation (§3.4.22.1). Specifically, leading zeroes are prohibited.
The unsignedInt datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The unsignedInt datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from unsignedInt may also specify values for the following ·constraining facets·:
The unsignedInt datatype has the following values for its ·fundamental facets·:
The following ·built-in· datatype is ·derived· from unsignedInt
[Definition:] unsignedShort is ·derived· from unsignedInt by setting the value of ·maxInclusive· to be 65535. The ·base type· of unsignedShort is unsignedInt.
unsignedShort
has a lexical representation consisting of
an optional sign followed by a
non-empty finite-length
sequence of decimal digits (#x30-#x39). If the sign is omitted, the positive sign
('+
') is assumed. If the sign is present, it
must
be
'+
' except for lexical forms denoting zero, which may
be preceded by a positive ('+
') or a negative
('-
') sign. For example: 0, 12678, 10000.
The ·canonical representation· for unsignedShort is defined by prohibiting certain options from the Lexical representation (§3.4.23.1). Specifically, the leading zeroes are prohibited.
The unsignedShort datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The unsignedShort datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from unsignedShort may also specify values for the following ·constraining facets·:
The unsignedShort datatype has the following values for its ·fundamental facets·:
The following ·built-in· datatype is ·derived· from unsignedShort
[Definition:] unsignedByte is ·derived· from unsignedShort by setting the value of ·maxInclusive· to be 255. The ·base type· of unsignedByte is unsignedShort.
unsignedByte
has a lexical representation consisting of
an optional sign followed by a
non-empty finite-length
sequence of decimal digits (#x30-#x39). If the sign is omitted, the positive sign
('+
') is assumed. If the sign is present, it
must
be '+
' except for lexical forms denoting zero, which may
be preceded by a positive ('+
') or a negative
('-
') sign. For example: 0, 126, 100.
The ·canonical representation· for unsignedByte is defined by prohibiting certain options from the Lexical representation (§3.4.24.1). Specifically, leading zeroes are prohibited.
The unsignedByte datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The unsignedByte datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from unsignedByte may also specify values for the following ·constraining facets·:
The unsignedByte datatype has the following values for its ·fundamental facets·:
[Definition:] positiveInteger is ·derived· from nonNegativeInteger by setting the value of ·minInclusive· to be 1. This results in the standard mathematical concept of the positive integer numbers. The ·value space· of positiveInteger is the infinite set {1,2,...}. The ·base type· of positiveInteger is nonNegativeInteger.
positiveInteger
has a lexical representation consisting
of an optional positive sign ('+
') followed by a
non-empty finite-length
sequence of decimal digits (#x30-#x39),
at least one of which must be a digit other than '0
'.
For example: 1, 12678967543233, +100000.
The ·canonical representation· for positiveInteger is defined by prohibiting certain options from the Lexical representation (§3.4.25.1). Specifically, the optional "+" sign is prohibited and leading zeroes are prohibited.
The positiveInteger datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The positiveInteger datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from positiveInteger may also specify values for the following ·constraining facets·:
The positiveInteger datatype has the following values for its ·fundamental facets·:
[Definition:] yearMonthDuration is a datatype ·derived· from duration by restricting its ·lexical representations· to instances of yearMonthDurationLexicalRep. The ·value space· of yearMonthDuration is therefore that of duration restricted to those whose ·seconds· property is 0. This results in a duration datatype which is totally ordered.
The lexical
space of yearMonthDuration consists of
strings which match the regular expression
'-?P((([0-9]+Y)([0-9]+M)?)|([0-9]+M))
' or the
expression '-?P[0-9]+(Y([0-9]+M)?|M)
', but the
formal definition of yearMonthDuration uses a
simpler regular expression in its ·pattern·
facet: '[^DT]*
'. This pattern matches only
strings of characters which contain no 'D'
and no 'T', thus restricting the ·lexical space·
of duration to strings with no day, hour,
minute, or seconds fields.
The ·canonical mapping· is that of duration restricted in its range to the ·lexical space· (which reduces its domain to omit any values not in the yearMonthDuration value space).
PT0S
')
is not in the
·lexical space· of yearMonthDuration.The yearMonthDuration datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The yearMonthDuration datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from yearMonthDuration may also specify values for the following ·constraining facets·:
The yearMonthDuration datatype has the following values for its ·fundamental facets·:
[Definition:] dayTimeDuration is a datatype ·derived· from duration by restricting its ·lexical representations· to instances of dayTimeDurationLexicalRep. The ·value space· of dayTimeDuration is therefore that of duration restricted to those whose ·months· property is 0. This results in a duration datatype which is totally ordered.
The lexical space is reduced from that of duration by disallowing duYearFrag and duMonthFrag fragments in the ·lexical representations·.
The lexical space of
dayTimeDuration consists of
strings in the ·lexical space· of duration which
match the regular expression '[^YM]*[DT].*
';
this pattern eliminates all durations with year or month fields,
leaving only those with day, hour, minutes, and/or seconds
fields.
The ·canonical mapping· is that of duration restricted in its range to the ·lexical space· (which reduces its domain to omit any values not in the dayTimeDuration value space).
The dayTimeDuration datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
The dayTimeDuration datatype has the following ·constraining facets· with the values shown; these facets may be specified in the derivation of new types, if the value given is at least as restrictive as the one shown:
Datatypes derived by restriction from dayTimeDuration may also specify values for the following ·constraining facets·:
The dayTimeDuration datatype has the following values for its ·fundamental facets·:
[Definition:] The dateTimeStamp datatype is ·derived· from dateTime by giving the value required to its explicitTimezone facet. The result is that all values of dateTimeStamp are required to have explicit time zone offsets and the datatype is totally ordered.
As a consequence of requiring an explicit time zone offset, the lexical space of dateTimeStamp is reduced from that of dateTime by requiring a timezoneFrag fragment in the ·lexical representations·.
-
' monthFrag '-
' dayFrag 'T
' ((hourFrag ':
' minuteFrag ':
' secondFrag) |
endOfDayFrag) timezoneFrag Constraint: Day-of-month RepresentationsIn other words, the lexical space of dateTimeStamp consists of strings which are in the
·lexical space· of dateTime and which
also match the regular expression
'.*(Z|(\+|-)[0-9][0-9]:[0-9][0-9])
'.
The ·lexical mapping· is that of dateTime restricted to the dateTimeStamp lexical space.
The ·canonical mapping· is that of dateTime restricted to the dateTimeStamp value space.
The dateTimeStamp datatype and all datatypes derived from it by restriction have the following ·constraining facets· with fixed values; these facets must not be changed from the values shown:
Datatypes derived by restriction from dateTimeStamp may also specify values for the following ·constraining facets·:
The dateTimeStamp datatype has the following values for its ·fundamental facets·:
The preceding sections of this specification have described datatypes in a way largely independent of their use in the particular context of schema-aware processing as defined in [XSD 1.1 Part 1: Structures].
This section presents the mechanisms necessary to integrate datatypes into the context of [XSD 1.1 Part 1: Structures], mostly in terms of the schema component abstraction introduced there. The account of datatypes given in this specification is also intended to be useful in other contexts. Any specification or other formal system intending to use datatypes as defined above, particularly if definition of new datatypes via facet-based restriction is envisaged, will need to provide analogous mechanisms for some, but not necessarily all, of what follows below. For example, the {target namespace} and {final} properties are required because of particular aspects of [XSD 1.1 Part 1: Structures] which are not in principle necessary for the use of datatypes as defined here.
The following sections provide full details on the properties and significance of each kind of schema component involved in datatype definitions. For each property, the kinds of values it is allowed to have is specified. Any property not identified as optional is required to be present; optional properties which are not present have absent as their value. Any property identified as a having a set, subset or ·list· value may have an empty value unless this is explicitly ruled out: this is not the same as absent. Any property value identified as a superset or a subset of some set may be equal to that set, unless a proper superset or subset is explicitly called for.
For more information on the notion of schema components, see Schema Component Details of [XSD 1.1 Part 1: Structures].
[Definition:] A component may be referred to as the owner of its properties, and of the values of those properties.
Simple Type Definitions provide for:
The Simple Type Definition schema component has the following properties:
Either an Attribute Declaration, an Element Declaration, a Complex Type Definition or a Simple Type Definition.
With one exception, the {base type definition} of any Simple Type Definition is a Simple Type Definition. The exception is ·anySimpleType·, which has anyType, a Complex Type Definition, as its {base type definition}.
If not absent, must be a ·primitive· built-in definition.
The value of this property must be a primitive or ordinary simple type definition with {variety} = atomic, or an ordinary simple type definition with {variety} = union whose basic members are all atomic; the value must not itself be a list type (have {variety} = list) or have any basic members which are list types.
Must be present (but may be empty) if {variety} is union, otherwise must be absent.
The sequence may contain any primitive or ordinary simple type definition, but must not contain any special type definitions.
Simple type definitions are identified by their {name} and {target namespace}. Except for anonymous Simple Type Definitions (those with no {name}), Simple Type Definitions must be uniquely identified within a schema. Within a valid schema, each Simple Type Definition uniquely determines one datatype. The ·value space·, ·lexical space·, ·lexical mapping·, etc., of a Simple Type Definition are the ·value space·, ·lexical space·, etc., of the datatype uniquely determined (or "defined") by that Simple Type Definition.
If {variety} is ·atomic· then the ·value space· of the datatype defined will be a subset of the ·value space· of {base type definition} (which is a subset of the ·value space· of {primitive type definition}). If {variety} is ·list· then the ·value space· of the datatype defined will be the set of (possibly empty) finite-length sequences of values from the ·value space· of {item type definition}. If {variety} is ·union· then the ·value space· of the datatype defined will be a subset (possibly an improper subset) of the union of the ·value spaces· of each Simple Type Definition in {member type definitions}.
If {variety} is ·atomic· then the {variety} of {base type definition} must be ·atomic·, unless the {base type definition} is anySimpleType. If {variety} is ·list· then the {variety} of {item type definition} must be either ·atomic· or ·union·, and if {item type definition} is ·union· then all its ·basic members· must be ·atomic·. If {variety} is ·union· then {member type definitions} must be a list of Simple Type Definitions.
The {facets} property determines the ·value space· and ·lexical space· of the datatype being defined by imposing constraints which are to be satisfied by all valid values and ·lexical representations·.
The {fundamental facets} property provides some basic information about the datatype being defined: its cardinality, whether an ordering is defined for it by this specification, whether it has upper and lower bounds, and whether it is numeric.
If {final} is the empty set then the type can be used in deriving other types; the explicit values restriction, list and union prevent further derivations of Simple Type Definitions by ·facet-based restriction·, ·list· and ·union· respectively; the explicit value extension prevents any derivation of Complex Type Definitions by extension.
The {context} property is only relevant for anonymous type definitions, for which its value is the component in which this type definition appears as the value of a property, e.g. {item type definition} or {base type definition}.
The XML representation for a Simple Type Definition schema component is a <simpleType> element information item. The correspondences between the properties of the information item and properties of the component are as follows:
simpleType
Element Information Item et al.targetNamespace
[attribute]
of the parent schema
element information
item, if present,
otherwise absent.base
[attribute] of <restriction>,
if present, otherwise the
type definition corresponding to the <simpleType> among
the [children] of <restriction>.{
restriction, extension, list,
union}
, determined as follows.
[Definition:] Let
FS be
the actual value of the
final
[attribute],
if present, otherwise the actual value of the
finalDefault
[attribute] of the ancestor
schema
element,
if present, otherwise the empty string. Then the property value is
the appropriate case among the following:
SKU
'
(the barcode number that appears on products) from the
·built-in· datatype string by
supplying a value for the ·pattern· facet.
<simpleType name='SKU'> <restriction base='string'> <pattern value='\d{3}-[A-Z]{2}'/> </restriction> </simpleType>
SKU
' is the name of the new
·user-defined· datatype, string is
its ·base type·
and
·pattern· is the facet.
itemType
[attribute] of <list>,
or (b)
corresponding to the <simpleType> among
the [children] of <list>, whichever is present.
itemType
[attribute] or a <simpleType> [child], but not both.<simpleType name='listOfFloat'> <list itemType='float'/> </simpleType>
memberTypes
[attribute] of <union>, if
any, and (b) those corresponding to the <simpleType>s
among the [children] of <union>, if any, in order.
memberTypes
[attribute] or one or more <simpleType> [children],
or both.<xs:attribute name="size"> <xs:simpleType> <xs:union> <xs:simpleType> <xs:restriction base="xs:positiveInteger"> <xs:minInclusive value="8"/> <xs:maxInclusive value="72"/> </xs:restriction> </xs:simpleType> <xs:simpleType> <xs:restriction base="xs:NMTOKEN"> <xs:enumeration value="small"/> <xs:enumeration value="medium"/> <xs:enumeration value="large"/> </xs:restriction> </xs:simpleType> </xs:union> </xs:simpleType> </xs:attribute>
<p> <font size='large'>A header</font> </p> <p> <font size='12'>this is a test</font> </p>
A datatype can be ·constructed· from a ·primitive· datatype or an ·ordinary· datatype by one of three means: by ·facet-based restriction·, by ·list· or by ·union·.
itemType
[attribute] or the
<simpleType> [child] of the <list> element
must
be present, but not both.
base
[attribute] or the
simpleType
[child] of the <restriction>
element
must
be present, but not both.
memberTypes
[attribute] of the <union>
element
must
be non-empty or
there
must
be at least one simpleType
[child].
If {variety} is absent, then no facets are applicable. (This is true for anySimpleType.)
If {variety} is list, then the applicable facets are assertions, length, minLength, maxLength, pattern, enumeration, and whiteSpace.
If {variety} is union, then the applicable facets are pattern, enumeration, and assertions.
If {variety} is atomic, and {primitive type definition} is absent then no facets are applicable. (This is true for anyAtomicType.)
In all other cases ({variety} is atomic and {primitive type definition} is not absent), then the applicable facets are shown in the table below.
The Simple Type Definition of anySimpleType is present in every schema. It has the following properties:
anySimpleType
'http://www.w3.org/2001/XMLSchema
'The definition of anySimpleType is the root of the Simple Type Definition hierarchy; as such it mediates between the other simple type definitions, which all eventually trace back to it via their {base type definition} properties, and the definition of anyType, which is its {base type definition}.
The Simple Type Definition of anyAtomicType is present in every schema. It has the following properties:
anyAtomicType
'http://www.w3.org/2001/XMLSchema
'Simple type definitions for all the built-in primitive datatypes, namely string, boolean, float, double, decimal, dateTime, duration, time, date, gMonth, gMonthDay, gDay, gYear, gYearMonth, hexBinary, base64Binary, anyURI are present by definition in every schema. All have a very similar structure, with only the {name}, the {primitive type definition} (which is self-referential), the {fundamental facets}, and in one case the {facets} varying from one to the next:
http://www.w3.org/2001/XMLSchema
'http://www.w3.org/2001/XMLSchema
' for the
{target namespace}
property. That namespace is controlled by the W3C and
datatypes will be added to it only by W3C or its designees.
Similarly, Simple Type Definitions for all the built-in ·ordinary· datatypes are present by definition in every schema, with properties as specified in Other Built-in Datatypes (§3.4) and as represented in XML in Illustrative XML representations for the built-in ordinary type definitions (§C.2).
http://www.w3.org/2001/XMLSchema
'[Definition:] Each fundamental facet is a schema component that provides a limited piece of information about some aspect of each datatype. All ·fundamental facet· components are defined in this section. For example, cardinality is a ·fundamental facet·. Most ·fundamental facets· are given a value fixed with each primitive datatype's definition, and this value is not changed by subsequent ·derivations· (even when it would perhaps be reasonable to expect an application to give a more accurate value based on the constraining facets used to define the ·derivation·). The cardinality and bounded facets are exceptions to this rule; their values may change as a result of certain ·derivations·.
A ·fundamental facet· can occur only in the {fundamental facets} of a Simple Type Definition, and this is the only place where ·fundamental facet· components occur. Each kind of ·fundamental facet· component occurs (once) in each Simple Type Definition's {fundamental facets} set.
For some datatypes, this document specifies an order relation for their value spaces (see Order (§2.2.3)); the ordered facet reflects this. It takes the values total, partial, and false, with the meanings described below. For the ·primitive· datatypes, the value of the ordered facet is specified in Fundamental Facets (§F.1). For ·ordinary· datatypes, the value is inherited without change from the ·base type·. For a ·list·, the value is always false; for a ·union·, the value is computed as described below.
A false value means no order is prescribed; a total value assures that the prescribed order is a total order; a partial value means that the prescribed order is a partial order, but not (for the primitive type in question) a total order.
[Definition:] A ·value space·, and hence a datatype, is said to be ordered if some members of the ·value space· are drawn from a ·primitive· datatype for which the table in Fundamental Facets (§F.1) specifies the value total or partial for the ordered facet.
Some ordered datatypes have the property that there is one value greater than or equal to every other value, and another that is less than or equal to every other value. (In the case of ·ordinary· datatypes, these two values are not necessarily in the value space of the derived datatype, but they will always be in the value space of the primitive datatype from which they have been derived.) The bounded facet value is boolean and is generally true for such bounded datatypes. However, it will remain false when the mechanism for imposing such a bound is difficult to detect, as, for example, when the boundedness occurs because of derivation using a pattern component.
{value} depends on the ·owner's· {variety}, {facets} and {member type definitions}.
When the ·owner· is ·primitive·, {value} is as specified in the table in Fundamental Facets (§F.1). Otherwise, when the ·owner's· {variety} is atomic, if one of minInclusive or minExclusive and one of maxInclusive or maxExclusive are members of the ·owner's· {facets} set, then {value} is true; otherwise {value} is false.
When the ·owner's· {variety} is list, {value} is false.
When the ·owner's· {variety} is union, if {value} is true for every member of the ·owner's· {member type definitions} set and all of the ·owner's· ·basic members· have the same {primitive type definition}, then {value} is true; otherwise {value} is false.
Every value space has a specific number of members. This number can be characterized as finite or infinite. (Currently there are no datatypes with infinite value spaces larger than countable.) The cardinality facet value is either finite or countably infinite and is generally finite for datatypes with finite value spaces. However, it will remain countably infinite when the mechanism for causing finiteness is difficult to detect, as, for example, when finiteness occurs because of a derivation using a pattern component.
{value} depends on the ·owner's· {variety}, {facets}, and {member type definitions}.
When the ·owner's· {variety} is list, if length or both minLength and maxLength are members of the ·owner's· {facets} set and the ·owner's· {item type definition}'s cardinality {value} is finite then {value} is finite; otherwise {value} is countably infinite.
When the ·owner's· {variety} is union, if cardinality's {value} is finite for every member of the ·owner's· {member type definitions} set then {value} is finite, otherwise {value} is countably infinite.
Some value spaces are made up of things that are conceptually numeric, others are not. The numeric facet value indicates which are considered numeric.
{value} depends on the ·owner's· {variety}, {facets}, {base type definition} and {member type definitions}.
When the ·owner· is ·primitive·, {value} is as specified in the table in Fundamental Facets (§F.1). Otherwise, when the ·owner's· {variety} is atomic, {value} is inherited from the ·owner's· {base type definition}'s numeric{value}.
When the ·owner's· {variety} is list, {value} is false.
When the ·owner's· {variety} is union, if numeric's {value} is true for every member of the ·owner's· {member type definitions} set then {value} is true, otherwise {value} is false.
[Definition:] Constraining facets are schema components whose values may be set or changed during ·derivation· (subject to facet-specific controls) to control various aspects of the derived datatype. All ·constraining facet· components defined by this specification are defined in this section. For example, whiteSpace is a ·constraining facet·. ·Constraining Facets· are given a value as part of the ·derivation· when an ·ordinary· datatype is defined by ·restricting· a ·primitive· or ·ordinary· datatype; a few ·constraining facets· have default values that are also provided for ·primitive· datatypes.
Conforming processors must support all the facets defined in this section. It is ·implementation-defined· whether a processor supports other constraining facets. [Definition:] An ·constraining facet· which is not supported by the processor in use is unknown.
The descriptions of individual facets given below include both constraints on Simple Type Definition components and rules for checking the datatype validity of a given literal against a given datatype. The validation rules typically depend upon having a full knowledge of the datatype; full knowledge of the datatype, in turn, depends on having a fully instantiated Simple Type Definition. A full instantiation of the Simple Type Definition, and the checking of the component constraints, require knowledge of the ·base type·. It follows that if a datatype's ·base type· is ·unknown·, the Simple Type Definition defining the datatype will be incompletely instantiated, and the datatype itself will be ·unknown·. Similarly, any datatype defined using an ·unknown· ·constraining facet· will be ·unknown·. It is not possible to perform datatype validation as defined here using ·unknown· datatypes.
[Definition:] length is the number of units of length, where units of length varies depending on the type that is being ·derived· from. The value of length must be a nonNegativeInteger.
For string and datatypes ·derived· from string, length is measured in units of characters as defined in [XML]. For anyURI, length is measured in units of characters (as for string). For hexBinary and base64Binary and datatypes ·derived· from them, length is measured in octets (8 bits) of binary data. For datatypes ·constructed· by ·list·, length is measured in number of list items.
·length· provides for:
<simpleType name='productCode'> <restriction base='string'> <length value='8' fixed='true'/> </restriction> </simpleType>
If {fixed} is true, then types for which the current type is the {base type definition} cannot specify a value for length other than {value}.
The XML representation for a length schema component is a <length> element information item. The correspondences between the properties of the information item and properties of the component are as follows:
length
Element Information ItemThe use of ·length· on QName, NOTATION, and datatypes ·derived· from them is deprecated. Future versions of this specification may remove this facet for these datatypes.
[Definition:] minLength is the minimum number of units of length, where units of length varies depending on the type that is being ·derived· from. The value of minLength must be a nonNegativeInteger.
For string and datatypes ·derived· from string, minLength is measured in units of characters as defined in [XML]. For hexBinary and base64Binary and datatypes ·derived· from them, minLength is measured in octets (8 bits) of binary data. For datatypes ·constructed· by ·list·, minLength is measured in number of list items.
·minLength· provides for:
<simpleType name='non-empty-string'> <restriction base='string'> <minLength value='1'/> </restriction> </simpleType>
If {fixed} is true, then types for which the current type is the {base type definition} cannot specify a value for minLength other than {value}.
The XML representation for a minLength schema component is a <minLength> element information item. The correspondences between the properties of the information item and properties of the component are as follows:
minLength
Element Information ItemThe use of ·minLength· on QName, NOTATION, and datatypes ·derived· from them is deprecated. Future versions of this specification may remove this facet for these datatypes.
[Definition:] maxLength is the maximum number of units of length, where units of length varies depending on the type that is being ·derived· from. The value of maxLength must be a nonNegativeInteger.
For string and datatypes ·derived· from string, maxLength is measured in units of characters as defined in [XML]. For hexBinary and base64Binary and datatypes ·derived· from them, maxLength is measured in octets (8 bits) of binary data. For datatypes ·constructed· by ·list·, maxLength is measured in number of list items.
·maxLength· provides for:
<simpleType name='form-input'> <restriction base='string'> <maxLength value='50'/> </restriction> </simpleType>
If {fixed} is true, then types for which the current type is the {base type definition} cannot specify a value for maxLength other than {value}.
The XML representation for a maxLength schema component is a <maxLength> element information item. The correspondences between the properties of the information item and properties of the component are as follows:
maxLength
Element Information ItemThe use of ·maxLength· on QName, NOTATION, and datatypes ·derived· from them is deprecated. Future versions of this specification may remove this facet for these datatypes.
[Definition:] pattern is a constraint on the ·value space· of a datatype which is achieved by constraining the ·lexical space· to ·literals· which match each member of a set of ·regular expressions·. The value of pattern must be a set of ·regular expressions·.
·pattern· provides for:
<simpleType name='better-us-zipcode'> <restriction base='string'> <pattern value='[0-9]{5}(-[0-9]{4})?'/> </restriction> </simpleType>
The XML representation for a pattern schema component is one or more <pattern> element information items. The correspondences between the properties of the information item and properties of the component are as follows:
pattern
Element Information Itemvalue
[attribute]value
[attributes], in order,
separated by '|
', so forming a single regular expression with multiple
·branches·.value
[attribute] must be a
·regular expression· as
defined in Regular Expressions (§G).[Definition:] enumeration constrains the ·value space· to a specified set of values.
enumeration does not impose an order relation on the ·value space· it creates; the value of the ·ordered· property of the ·derived· datatype remains that of the datatype from which it is ·derived·.
·enumeration· provides for:
<simpleType name='holidays'> <annotation> <documentation>some US holidays</documentation> </annotation> <restriction base='gMonthDay'> <enumeration value='--01-01'> <annotation> <documentation>New Year's day</documentation> </annotation> </enumeration> <enumeration value='--07-04'> <annotation> <documentation>4th of July</documentation> </annotation> </enumeration> <enumeration value='--12-25'> <annotation> <documentation>Christmas</documentation> </annotation> </enumeration> </restriction> </simpleType>
The XML representation for an enumeration schema component is one or more <enumeration> element information items. The correspondences between the properties of the information item and properties of the component are as follows:
enumeration
Element Information Itemvalue
[attribute],
interpreted as an instance of
the {base type definition}.value
[attributes], interpreted as instances of
the {base type definition}.value
[attribute] is declared as having
type ·anySimpleType
·, but the
{value} property of the
enumeration facet must be a member of the
{base type definition}.
So in mapping from the XML representation
to the enumeration component, the actual value is
identified by using the ·lexical mapping· of the
{base type definition}.
value
[attribute] must be
Datatype Valid (§4.1.4) with respect to the
{base type definition} of the Simple Type Definition
corresponding to the
nearest
<simpleType> ancestor
element.[Definition:] whiteSpace constrains the ·value space· of types ·derived· from string such that the various behaviors specified in Attribute Value Normalization in [XML] are realized. The value of whiteSpace must be one of {preserve, replace, collapse}.
hexadecimal A
(line feed), which is denoted by
U+000A. This notation is to be distinguished from


, which is the XML character reference to that same UCS
code point.
whiteSpace is applicable to all ·atomic· and
·list· datatypes. For all ·atomic·
datatypes other than string (and types ·derived·
by ·facet-based restriction· from it) the value of whiteSpace is
collapse
and cannot be changed by a schema author; for
string the value of whiteSpace is
preserve
; for any type ·derived· by
·facet-based restriction· from
string the value of whiteSpace can
be any of the three legal values
(as long as the value is at least as restrictive as
the value of the ·base type·; see
Constraints on whiteSpace Schema Components (§4.3.6.4)). For all datatypes
·constructed· by ·list· the
value of whiteSpace is collapse
and cannot
be changed by a schema author. For all datatypes
·constructed· by ·union·
whiteSpace does not apply directly; however, the
normalization behavior of ·union· types is controlled by
the value of whiteSpace on that one of the
·basic members·
against which the ·union·
is successfully validated.
·whiteSpace· provides for:
<simpleType name='token'> <restriction base='normalizedString'> <whiteSpace value='collapse'/> </restriction> </simpleType>
replace
" and
"collapse
" may appear to provide a
convenient way to "unwrap" text (i.e. undo the effects of
pretty-printing and word-wrapping). In some cases, especially
highly constrained data consisting of lists of artificial tokens
such as part numbers or other identifiers, this appearance is
correct. For natural-language data, however, the whitespace
processing prescribed for these values is not only unreliable but
will systematically remove the information needed to perform
unwrapping correctly. For Asian scripts, for example, a correct
unwrapping process will replace line boundaries not with blanks but
with zero-width separators or nothing. In consequence, it is
normally unwise to use these values for natural-language data, or
for any data other than lists of highly constrained tokens.If {fixed} is true, then types for which the current type is the {base type definition} cannot specify a value for whiteSpace other than {value}.
The XML representation for a whiteSpace schema component is a <whiteSpace> element information item. The correspondences between the properties of the information item and properties of the component are as follows:
whiteSpace
Element Information Item[Definition:] maxInclusive is the inclusive upper bound of the ·value space· for a datatype with the ·ordered· property. The value of maxInclusive must be equal to some value in the ·value space· of the ·base type·.
·maxInclusive· provides for:
<simpleType name='one-hundred-or-less'> <restriction base='integer'> <maxInclusive value='100'/> </restriction> </simpleType>
If {fixed} is true, then types for which the current type is the {base type definition} cannot specify a value for maxInclusive other than {value}.
The XML representation for a maxInclusive schema component is a <maxInclusive> element information item. The correspondences between the properties of the information item and properties of the component are as follows:
maxInclusive
Element Information Item[Definition:] maxExclusive is the exclusive upper bound of the ·value space· for a datatype with the ·ordered· property. The value of maxExclusive must be equal to some value in the ·value space· of the ·base type· or be equal to {value} in {base type definition}.
·maxExclusive· provides for:
<simpleType name='less-than-one-hundred-and-one'> <restriction base='integer'> <maxExclusive value='101'/> </restriction> </simpleType>
If {fixed} is true, then types for which the current type is the {base type definition} cannot specify a value for maxExclusive other than {value}.
The XML representation for a maxExclusive schema component is a <maxExclusive> element information item. The correspondences between the properties of the information item and properties of the component are as follows:
maxExclusive
Element Information Item[Definition:] minExclusive is the exclusive lower bound of the ·value space· for a datatype with the ·ordered· property. The value of minExclusive must be equal to some value in the ·value space· of the ·base type· or be equal to {value} in {base type definition}.
·minExclusive· provides for:
<simpleType name='more-than-ninety-nine'> <restriction base='integer'> <minExclusive value='99'/> </restriction> </simpleType>
If {fixed} is true, then types for which the current type is the {base type definition} cannot specify a value for minExclusive other than {value}.
The XML representation for a minExclusive schema component is a <minExclusive> element information item. The correspondences between the properties of the information item and properties of the component are as follows:
minExclusive
Element Information Item[Definition:] minInclusive is the inclusive lower bound of the ·value space· for a datatype with the ·ordered· property. The value of minInclusive must be equal to some value in the ·value space· of the ·base type·.
·minInclusive· provides for:
<simpleType name='one-hundred-or-more'> <restriction base='integer'> <minInclusive value='100'/> </restriction> </simpleType>
If {fixed} is true, then types for which the current type is the {base type definition} cannot specify a value for minInclusive other than {value}.
The XML representation for a minInclusive schema component is a <minInclusive> element information item. The correspondences between the properties of the information item and properties of the component are as follows:
minInclusive
Element Information Item[Definition:] totalDigits restricts the magnitude and arithmetic precision of values in the ·value spaces· of decimal and datatypes derived from it.
For decimal, if the {value} of totalDigits is t, the effect is to require that values be equal to i / 10n, for some integers i and n, with | i | < 10t and 0 ≤ n ≤ t. This has as a consequence that the values are expressible using at most t digits in decimal notation.
The {value} of totalDigits must be a positiveInteger.
The term 'totalDigits' is chosen to reflect the fact that it restricts the ·value space· to those values that can be represented lexically using at most totalDigits digits in decimal notation, or at most totalDigits digits for the coefficient, in scientific notation. Note that it does not restrict the ·lexical space· directly; a lexical representation that adds non-significant leading or trailing zero digits is still permitted. It also has no effect on the values NaN, INF, and -INF.
If {fixed} is true, then types for which the current type is the {base type definition} must not specify a value for totalDigits other than {value}.
The XML representation for a totalDigits schema component is a <totalDigits> element information item. The correspondences between the properties of the information item and properties of the component are as follows:
totalDigits
Element Information Item[Definition:] fractionDigits places an upper limit on the arithmetic precision of decimal values: if the {value} of fractionDigits = f, then the value space is restricted to values equal to i / 10n for some integers i and n and 0 ≤ n ≤ f. The value of fractionDigits must be a nonNegativeInteger
The term fractionDigits is chosen to reflect the fact that it restricts the ·value space· to those values that can be represented lexically in decimal notation using at most fractionDigits to the right of the decimal point. Note that it does not restrict the ·lexical space· directly; a lexical representation that adds non-significant leading or trailing zero digits is still permitted.
<simpleType name='celsiusBodyTemp'> <restriction base='decimal'> <fractionDigits value='1'/> <minInclusive value='32'/> <maxInclusive value='41.7'/> </restriction> </simpleType>
If {fixed} is true, then types for which the current type is the {base type definition} must not specify a value for fractionDigits other than {value}.
The XML representation for a fractionDigits schema component is a <fractionDigits> element information item. The correspondences between the properties of the information item and properties of the component are as follows:
fractionDigits
Element Information Item[Definition:] Assertions constrain the ·value space· by requiring the values to satisfy specified XPath ([XPath 2.0]) expressions. The value of the assertions facet is a sequence of Assertion components as defined in [XSD 1.1 Part 1: Structures].
The following is the definition of a ·user-defined· datatype which allows all integers but 0 by using an assertion to disallow the value 0.
<simpleType name='nonZeroInteger'> <restriction base='integer'> <assertion test='$value ne 0'/> </restriction> </simpleType>
The following example defines the datatype "triple", whose ·value space· is the set of integers evenly divisible by three.
<simpleType name='triple'> <restriction base='integer'> <assertion test='$value mod 3 eq 0'/> </restriction> </simpleType>
The same datatype can be defined without the use of assertions, but the pattern necessary to represent the set of triples is long and error-prone:
<simpleType name='triple'> <restriction base='integer'> <pattern value= "([0369]|[147][0369]*[258]|(([258]|[147][0369]*[147])([0369]|[258][0369]*[147])*([147]|[258][0369]*[258]))*"/> </restriction> </simpleType>
The assertion used in the first version of "triple" is likely to be clearer for many readers of the schema document.
The XML representation for an assertions schema component is one or more <assertion> element information items. The correspondences between the properties of the information item and properties of the component are as follows:
assertion
Element Information ItemThe following rule refers to "the nearest built-in" datatype and to the "XDM representation" of a value under a datatype. [Definition:] For any datatype T, the nearest built-in datatype to T is the first ·built-in· datatype encountered in following the chain of links connecting each datatype to its ·base type·. If T is a ·built-in· datatype, then the nearest built-in datatype of T is T itself; otherwise, it is the nearest built-in datatype of T's ·base type·.
xs:anySimpleType
· or ·xs:anyAtomicType
· then X is V,
and the dynamic
type of X is xs:untypedAtomic
.
true
under the
conditions laid out below, without raising any
dynamic error or
type error.expanded QName
of that member has no namespace
URI and
has
'value
' as the local
name. The (static) type
of the member is
anyAtomicType*
.
anyAtomicType*
simply says
that for static typing purposes the variable $value
will have a value consisting of a sequence of zero or more
atomic values.
.
',
or any implicit or
explicit reference to the context item, will raise a
dynamic error, which will cause the assertion to be treated as false.
If an error is detected statically, then the assertion
violates the schema component constraint
XPath Valid
and causes an error to be flagged in the schema.
$value
" can be
used to refer to the value being checked.
expanded QName
of that member has no
namespace URI
and 'value
' as the local
name. The value
of the member is
the
·XDM representation· of V
under T.
true
or
false
as if by a call to the XPath
fn:boolean function.[Definition:] explicitTimezone is a three-valued facet which can can be used to require or prohibit the time zone offset in date/time datatypes.
<simpleType name='bare-date'> <restriction base='date'> <explicitTimezone value='prohibited'/> </restriction> </simpleType>
<simpleType name='bare-date'> <restriction base='date'> <pattern value='[^:Z]*'/> </restriction> </simpleType>
If {fixed} is true, then datatypes for which the current type is the {base type definition} cannot specify a value for explicitTimezone other than {value}.
The XML representation for an explicitTimezone schema component is an <explicitTimezone> element information item. The correspondences between the properties of the information item and properties of the component are as follows:
explicitTimezone
Element Information ItemXSD 1.1: Datatypes is intended to be usable in a variety of contexts.
In the usual case, it will embedded in a host language such as [XSD 1.1 Part 1: Structures], which refers to this specification normatively to define some part of the host language. In some cases, XSD 1.1: Datatypes may be implemented independently of any host language.
When XSD 1.1: Datatypes is embedded in a host language, the definition of conformance is specified by the host language, not by this specification. That is, when this specification is implemented in the context of an implementation of a host language, the question of conformance to this specification (separate from the host language) does not arise.
This specification imposes certain constraints on the embedding of XSD 1.1: Datatypes by a host language; these are indicated in the normative text by the use of the verbs 'must', etc., with the phrase "host language" as the subject of the verb.
In addition, host languages must require conforming implementations of the host language to obey all of the constraints and rules specified here.
Abstract representations of simple type definitions conform to this specification if and only if they obey all of the ·constraints on schemas· defined in this specification.
XML representations of simple type definitions conform to this specification if they obey all of the applicable rules defined in this specification.
Some ·primitive· datatypes defined in this specification have infinite ·value spaces·; no finite implementation can completely handle all their possible values. For some such datatypes, minimum implementation limits are specified below. For other infinite types such as string, hexBinary, and base64Binary, no minimum implementation limits are specified.
When this specification is used in the context of other languages (as it is, for example, by [XSD 1.1 Part 1: Structures]), the host language may specify other minimum implementation limits.
When presented with a literal or value exceeding the capacity of its partial implementation of a datatype, a minimally conforming implementation of this specification will sometimes be unable to determine with certainty whether the value is datatype-valid or not. Sometimes it will be unable to represent the value correctly through its interface to any downstream application.
When either of these is so, a conforming processor must indicate to the user and/or downstream application that it cannot process the input data with assured correctness (much as it would indicate if it ran out of memory). When the datatype validity of a value or literal is uncertain because it exceeds the capacity of a partial implementation, the literal or value must not be treated as invalid, and the unsupported value must not be quietly changed to a supported value.
This specification does not constrain the method used to indicate that a literal or value in the input data has exceeded the capacity of the implementation, or the form such indications take.
·Minimally conforming· processors which set an application- or ·implementation-defined· limit on the size of the values supported must clearly document that limit.
The XML representation of the datatypes-relevant part of the schema for schema documents is presented here as a normative part of the specification. Independent copies of this material are available in an undated (mutable) version at http://www.w3.org/2009/XMLSchema/datatypes.xsd and in a dated (immutable) version at http://www.w3.org/2012/04/datatypes.xsd — the mutable version will be updated with future revisions of this specification, and the immutable one will not.
Like any other
XML document, schema documents may carry XML and document type declarations. An
XML declaration and a document type declaration are provided here for convenience.
Since
this schema document describes the XML Schema language, the targetNamespace
attribute on the schema
element refers to the XML Schema namespace
itself.
Schema documents conforming to this specification may be in XML 1.0 or XML 1.1. Conforming implementations may accept input in XML 1.0 or XML 1.1 or both. See Dependencies on Other Specifications (§1.3).
<?xml version='1.0'?> <!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XSD 1.1//EN" "XMLSchema.dtd" [ <!-- Make sure that processors that do not read the external subset will know about the various IDs we declare --> <!ATTLIST xs:simpleType id ID #IMPLIED> <!ATTLIST xs:maxExclusive id ID #IMPLIED> <!ATTLIST xs:minExclusive id ID #IMPLIED> <!ATTLIST xs:maxInclusive id ID #IMPLIED> <!ATTLIST xs:minInclusive id ID #IMPLIED> <!ATTLIST xs:totalDigits id ID #IMPLIED> <!ATTLIST xs:fractionDigits id ID #IMPLIED> <!ATTLIST xs:length id ID #IMPLIED> <!ATTLIST xs:minLength id ID #IMPLIED> <!ATTLIST xs:maxLength id ID #IMPLIED> <!ATTLIST xs:enumeration id ID #IMPLIED> <!ATTLIST xs:pattern id ID #IMPLIED> <!ATTLIST xs:assertion id ID #IMPLIED> <!ATTLIST xs:explicitTimezone id ID #IMPLIED> <!ATTLIST xs:appinfo id ID #IMPLIED> <!ATTLIST xs:documentation id ID #IMPLIED> <!ATTLIST xs:list id ID #IMPLIED> <!ATTLIST xs:union id ID #IMPLIED> ]> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xml:lang="en" targetNamespace="http://www.w3.org/2001/XMLSchema" version="datatypes.xsd (rec-20120405)"> <xs:annotation> <xs:documentation source="../datatypes/datatypes.html"> The schema corresponding to this document is normative, with respect to the syntactic constraints it expresses in the XML Schema language. The documentation (within 'documentation' elements) below, is not normative, but rather highlights important aspects of the W3C Recommendation of which this is a part. See below (at the bottom of this document) for information about the revision and namespace-versioning policy governing this schema document. </xs:documentation> </xs:annotation> <xs:simpleType name="derivationControl"> <xs:annotation> <xs:documentation> A utility type, not for public use</xs:documentation> </xs:annotation> <xs:restriction base="xs:NMTOKEN"> <xs:enumeration value="substitution"/> <xs:enumeration value="extension"/> <xs:enumeration value="restriction"/> <xs:enumeration value="list"/> <xs:enumeration value="union"/> </xs:restriction> </xs:simpleType> <xs:group name="simpleDerivation"> <xs:choice> <xs:element ref="xs:restriction"/> <xs:element ref="xs:list"/> <xs:element ref="xs:union"/> </xs:choice> </xs:group> <xs:simpleType name="simpleDerivationSet"> <xs:annotation> <xs:documentation> #all or (possibly empty) subset of {restriction, extension, union, list} </xs:documentation> <xs:documentation> A utility type, not for public use</xs:documentation> </xs:annotation> <xs:union> <xs:simpleType> <xs:restriction base="xs:token"> <xs:enumeration value="#all"/> </xs:restriction> </xs:simpleType> <xs:simpleType> <xs:list> <xs:simpleType> <xs:restriction base="xs:derivationControl"> <xs:enumeration value="list"/> <xs:enumeration value="union"/> <xs:enumeration value="restriction"/> <xs:enumeration value="extension"/> </xs:restriction> </xs:simpleType> </xs:list> </xs:simpleType> </xs:union> </xs:simpleType> <xs:complexType name="simpleType" abstract="true"> <xs:complexContent> <xs:extension base="xs:annotated"> <xs:group ref="xs:simpleDerivation"/> <xs:attribute name="final" type="xs:simpleDerivationSet"/> <xs:attribute name="name" type="xs:NCName"> <xs:annotation> <xs:documentation> Can be restricted to required or forbidden </xs:documentation> </xs:annotation> </xs:attribute> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="topLevelSimpleType"> <xs:complexContent> <xs:restriction base="xs:simpleType"> <xs:sequence> <xs:element ref="xs:annotation" minOccurs="0"/> <xs:group ref="xs:simpleDerivation"/> </xs:sequence> <xs:attribute name="name" type="xs:NCName" use="required"> <xs:annotation> <xs:documentation> Required at the top level </xs:documentation> </xs:annotation> </xs:attribute> <xs:anyAttribute namespace="##other" processContents="lax"/> </xs:restriction> </xs:complexContent> </xs:complexType> <xs:complexType name="localSimpleType"> <xs:complexContent> <xs:restriction base="xs:simpleType"> <xs:sequence> <xs:element ref="xs:annotation" minOccurs="0"/> <xs:group ref="xs:simpleDerivation"/> </xs:sequence> <xs:attribute name="name" use="prohibited"> <xs:annotation> <xs:documentation> Forbidden when nested </xs:documentation> </xs:annotation> </xs:attribute> <xs:attribute name="final" use="prohibited"/> <xs:anyAttribute namespace="##other" processContents="lax"/> </xs:restriction> </xs:complexContent> </xs:complexType> <xs:element name="simpleType" type="xs:topLevelSimpleType" id="simpleType"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-simpleType"/> </xs:annotation> </xs:element> <xs:element name="facet" abstract="true"> <xs:annotation> <xs:documentation> An abstract element, representing facets in general. The facets defined by this spec are substitutable for this element, and implementation-defined facets should also name this as a substitution-group head. </xs:documentation> </xs:annotation> </xs:element> <xs:group name="simpleRestrictionModel"> <xs:sequence> <xs:element name="simpleType" type="xs:localSimpleType" minOccurs="0"/> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="xs:facet"/> <xs:any processContents="lax" namespace="##other"/> </xs:choice> </xs:sequence> </xs:group> <xs:element name="restriction" id="restriction"> <xs:complexType> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-restriction"> base attribute and simpleType child are mutually exclusive, but one or other is required </xs:documentation> </xs:annotation> <xs:complexContent> <xs:extension base="xs:annotated"> <xs:group ref="xs:simpleRestrictionModel"/> <xs:attribute name="base" type="xs:QName" use="optional"/> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element> <xs:element name="list" id="list"> <xs:complexType> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-list"> itemType attribute and simpleType child are mutually exclusive, but one or other is required </xs:documentation> </xs:annotation> <xs:complexContent> <xs:extension base="xs:annotated"> <xs:sequence> <xs:element name="simpleType" type="xs:localSimpleType" minOccurs="0"/> </xs:sequence> <xs:attribute name="itemType" type="xs:QName" use="optional"/> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element> <xs:element name="union" id="union"> <xs:complexType> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-union"> memberTypes attribute must be non-empty or there must be at least one simpleType child </xs:documentation> </xs:annotation> <xs:complexContent> <xs:extension base="xs:annotated"> <xs:sequence> <xs:element name="simpleType" type="xs:localSimpleType" minOccurs="0" maxOccurs="unbounded"/> </xs:sequence> <xs:attribute name="memberTypes" use="optional"> <xs:simpleType> <xs:list itemType="xs:QName"/> </xs:simpleType> </xs:attribute> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element> <xs:complexType name="facet"> <xs:complexContent> <xs:extension base="xs:annotated"> <xs:attribute name="value" use="required"/> <xs:attribute name="fixed" type="xs:boolean" default="false" use="optional"/> </xs:extension> </xs:complexContent> </xs:complexType> <xs:complexType name="noFixedFacet"> <xs:complexContent> <xs:restriction base="xs:facet"> <xs:sequence> <xs:element ref="xs:annotation" minOccurs="0"/> </xs:sequence> <xs:attribute name="fixed" use="prohibited"/> <xs:anyAttribute namespace="##other" processContents="lax"/> </xs:restriction> </xs:complexContent> </xs:complexType> <xs:element name="minExclusive" type="xs:facet" id="minExclusive" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-minExclusive"/> </xs:annotation> </xs:element> <xs:element name="minInclusive" type="xs:facet" id="minInclusive" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-minInclusive"/> </xs:annotation> </xs:element> <xs:element name="maxExclusive" type="xs:facet" id="maxExclusive" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-maxExclusive"/> </xs:annotation> </xs:element> <xs:element name="maxInclusive" type="xs:facet" id="maxInclusive" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-maxInclusive"/> </xs:annotation> </xs:element> <xs:complexType name="numFacet"> <xs:complexContent> <xs:restriction base="xs:facet"> <xs:sequence> <xs:element ref="xs:annotation" minOccurs="0"/> </xs:sequence> <xs:attribute name="value" type="xs:nonNegativeInteger" use="required"/> <xs:anyAttribute namespace="##other" processContents="lax"/> </xs:restriction> </xs:complexContent> </xs:complexType> <xs:complexType name="intFacet"> <xs:complexContent> <xs:restriction base="xs:facet"> <xs:sequence> <xs:element ref="xs:annotation" minOccurs="0"/> </xs:sequence> <xs:attribute name="value" type="xs:integer" use="required"/> <xs:anyAttribute namespace="##other" processContents="lax"/> </xs:restriction> </xs:complexContent> </xs:complexType> <xs:element name="totalDigits" id="totalDigits" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-totalDigits"/> </xs:annotation> <xs:complexType> <xs:complexContent> <xs:restriction base="xs:numFacet"> <xs:sequence> <xs:element ref="xs:annotation" minOccurs="0"/> </xs:sequence> <xs:attribute name="value" type="xs:positiveInteger" use="required"/> <xs:anyAttribute namespace="##other" processContents="lax"/> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:element> <xs:element name="fractionDigits" type="xs:numFacet" id="fractionDigits" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-fractionDigits"/> </xs:annotation> </xs:element> <xs:element name="length" type="xs:numFacet" id="length" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-length"/> </xs:annotation> </xs:element> <xs:element name="minLength" type="xs:numFacet" id="minLength" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-minLength"/> </xs:annotation> </xs:element> <xs:element name="maxLength" type="xs:numFacet" id="maxLength" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-maxLength"/> </xs:annotation> </xs:element> <xs:element name="enumeration" type="xs:noFixedFacet" id="enumeration" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-enumeration"/> </xs:annotation> </xs:element> <xs:element name="whiteSpace" id="whiteSpace" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-whiteSpace"/> </xs:annotation> <xs:complexType> <xs:complexContent> <xs:restriction base="xs:facet"> <xs:sequence> <xs:element ref="xs:annotation" minOccurs="0"/> </xs:sequence> <xs:attribute name="value" use="required"> <xs:simpleType> <xs:restriction base="xs:NMTOKEN"> <xs:enumeration value="preserve"/> <xs:enumeration value="replace"/> <xs:enumeration value="collapse"/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:anyAttribute namespace="##other" processContents="lax"/> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:element> <xs:element name="pattern" id="pattern" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-pattern"/> </xs:annotation> <xs:complexType> <xs:complexContent> <xs:restriction base="xs:noFixedFacet"> <xs:sequence> <xs:element ref="xs:annotation" minOccurs="0"/> </xs:sequence> <xs:attribute name="value" type="xs:string" use="required"/> <xs:anyAttribute namespace="##other" processContents="lax"/> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:element> <xs:element name="assertion" type="xs:assertion" id="assertion" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-assertion"/> </xs:annotation> </xs:element> <xs:element name="explicitTimezone" id="explicitTimezone" substitutionGroup="xs:facet"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#element-explicitTimezone"/> </xs:annotation> <xs:complexType> <xs:complexContent> <xs:restriction base="xs:facet"> <xs:sequence> <xs:element ref="xs:annotation" minOccurs="0"/> </xs:sequence> <xs:attribute name="value" use="required"> <xs:simpleType> <xs:restriction base="xs:NMTOKEN"> <xs:enumeration value="optional"/> <xs:enumeration value="required"/> <xs:enumeration value="prohibited"/> </xs:restriction> </xs:simpleType> </xs:attribute> <xs:anyAttribute namespace="##other" processContents="lax"/> </xs:restriction> </xs:complexContent> </xs:complexType> </xs:element> <xs:annotation> <xs:documentation> In keeping with the XML Schema WG's standard versioning policy, this schema document will persist at the URI http://www.w3.org/2012/04/datatypes.xsd. At the date of issue it can also be found at the URI http://www.w3.org/2009/XMLSchema/datatypes.xsd. The schema document at that URI may however change in the future, in order to remain compatible with the latest version of XSD and its namespace. In other words, if XSD or the XML Schema namespace change, the version of this document at http://www.w3.org/2009/XMLSchema/datatypes.xsd will change accordingly; the version at http://www.w3.org/2012/04/datatypes.xsd will not change. Previous dated (and unchanging) versions of this schema document include: http://www.w3.org/2012/01/datatypes.xsd (XSD 1.1 Proposed Recommendation) http://www.w3.org/2011/07/datatypes.xsd (XSD 1.1 Candidate Recommendation) http://www.w3.org/2009/04/datatypes.xsd (XSD 1.1 Candidate Recommendation) http://www.w3.org/2004/10/datatypes.xsd (XSD 1.0 Recommendation, Second Edition) http://www.w3.org/2001/05/datatypes.xsd (XSD 1.0 Recommendation, First Edition) </xs:documentation> </xs:annotation> </xs:schema>
The DTD for the datatypes-specific
aspects of schema documents is given below. Note there is
no implication here that schema
must be
the root element of a document.
<!-- DTD for XML Schemas: Part 2: Datatypes Id: datatypes.dtd,v 1.1.2.4 2005/01/31 18:40:42 cmsmcq Exp Note this DTD is NOT normative, or even definitive. --> <!-- This DTD cannot be used on its own, it is intended only for incorporation in XMLSchema.dtd, q.v. --> <!-- Define all the element names, with optional prefix --> <!ENTITY % simpleType "%p;simpleType"> <!ENTITY % restriction "%p;restriction"> <!ENTITY % list "%p;list"> <!ENTITY % union "%p;union"> <!ENTITY % maxExclusive "%p;maxExclusive"> <!ENTITY % minExclusive "%p;minExclusive"> <!ENTITY % maxInclusive "%p;maxInclusive"> <!ENTITY % minInclusive "%p;minInclusive"> <!ENTITY % totalDigits "%p;totalDigits"> <!ENTITY % fractionDigits "%p;fractionDigits"> <!ENTITY % length "%p;length"> <!ENTITY % minLength "%p;minLength"> <!ENTITY % maxLength "%p;maxLength"> <!ENTITY % enumeration "%p;enumeration"> <!ENTITY % whiteSpace "%p;whiteSpace"> <!ENTITY % pattern "%p;pattern"> <!ENTITY % assertion "%p;assertion"> <!ENTITY % explicitTimezone "%p;explicitTimezone"> <!-- Customization entities for the ATTLIST of each element type. Define one of these if your schema takes advantage of the anyAttribute='##other' in the schema for schemas --> <!ENTITY % simpleTypeAttrs ""> <!ENTITY % restrictionAttrs ""> <!ENTITY % listAttrs ""> <!ENTITY % unionAttrs ""> <!ENTITY % maxExclusiveAttrs ""> <!ENTITY % minExclusiveAttrs ""> <!ENTITY % maxInclusiveAttrs ""> <!ENTITY % minInclusiveAttrs ""> <!ENTITY % totalDigitsAttrs ""> <!ENTITY % fractionDigitsAttrs ""> <!ENTITY % lengthAttrs ""> <!ENTITY % minLengthAttrs ""> <!ENTITY % maxLengthAttrs ""> <!ENTITY % enumerationAttrs ""> <!ENTITY % whiteSpaceAttrs ""> <!ENTITY % patternAttrs ""> <!ENTITY % assertionAttrs ""> <!ENTITY % explicitTimezoneAttrs ""> <!-- Define some entities for informative use as attribute types --> <!ENTITY % URIref "CDATA"> <!ENTITY % XPathExpr "CDATA"> <!ENTITY % QName "NMTOKEN"> <!ENTITY % QNames "NMTOKENS"> <!ENTITY % NCName "NMTOKEN"> <!ENTITY % nonNegativeInteger "NMTOKEN"> <!ENTITY % boolean "(true|false)"> <!ENTITY % simpleDerivationSet "CDATA"> <!-- #all or space-separated list drawn from derivationChoice --> <!-- Note that the use of 'facet' below is less restrictive than is really intended: There should in fact be no more than one of each of minInclusive, minExclusive, maxInclusive, maxExclusive, totalDigits, fractionDigits, length, maxLength, minLength within datatype, and the min- and max- variants of Inclusive and Exclusive are mutually exclusive. On the other hand, pattern and enumeration and assertion may repeat. --> <!ENTITY % minBound "(%minInclusive; | %minExclusive;)"> <!ENTITY % maxBound "(%maxInclusive; | %maxExclusive;)"> <!ENTITY % bounds "%minBound; | %maxBound;"> <!ENTITY % numeric "%totalDigits; | %fractionDigits;"> <!ENTITY % ordered "%bounds; | %numeric;"> <!ENTITY % unordered "%pattern; | %enumeration; | %whiteSpace; | %length; | %maxLength; | %minLength; | %assertion; | %explicitTimezone;"> <!ENTITY % implementation-defined-facets ""> <!ENTITY % facet "%ordered; | %unordered; %implementation-defined-facets;"> <!ENTITY % facetAttr "value CDATA #REQUIRED id ID #IMPLIED"> <!ENTITY % fixedAttr "fixed %boolean; #IMPLIED"> <!ENTITY % facetModel "(%annotation;)?"> <!ELEMENT %simpleType; ((%annotation;)?, (%restriction; | %list; | %union;))> <!ATTLIST %simpleType; name %NCName; #IMPLIED final %simpleDerivationSet; #IMPLIED id ID #IMPLIED %simpleTypeAttrs;> <!-- name is required at top level --> <!ELEMENT %restriction; ((%annotation;)?, (%restriction1; | ((%simpleType;)?,(%facet;)*)), (%attrDecls;))> <!ATTLIST %restriction; base %QName; #IMPLIED id ID #IMPLIED %restrictionAttrs;> <!-- base and simpleType child are mutually exclusive, one is required. restriction is shared between simpleType and simpleContent and complexContent (in XMLSchema.xsd). restriction1 is for the latter cases, when this is restricting a complex type, as is attrDecls. --> <!ELEMENT %list; ((%annotation;)?,(%simpleType;)?)> <!ATTLIST %list; itemType %QName; #IMPLIED id ID #IMPLIED %listAttrs;> <!-- itemType and simpleType child are mutually exclusive, one is required --> <!ELEMENT %union; ((%annotation;)?,(%simpleType;)*)> <!ATTLIST %union; id ID #IMPLIED memberTypes %QNames; #IMPLIED %unionAttrs;> <!-- At least one item in memberTypes or one simpleType child is required --> <!ELEMENT %maxExclusive; %facetModel;> <!ATTLIST %maxExclusive; %facetAttr; %fixedAttr; %maxExclusiveAttrs;> <!ELEMENT %minExclusive; %facetModel;> <!ATTLIST %minExclusive; %facetAttr; %fixedAttr; %minExclusiveAttrs;> <!ELEMENT %maxInclusive; %facetModel;> <!ATTLIST %maxInclusive; %facetAttr; %fixedAttr; %maxInclusiveAttrs;> <!ELEMENT %minInclusive; %facetModel;> <!ATTLIST %minInclusive; %facetAttr; %fixedAttr; %minInclusiveAttrs;> <!ELEMENT %totalDigits; %facetModel;> <!ATTLIST %totalDigits; %facetAttr; %fixedAttr; %totalDigitsAttrs;> <!ELEMENT %fractionDigits; %facetModel;> <!ATTLIST %fractionDigits; %facetAttr; %fixedAttr; %fractionDigitsAttrs;> <!ELEMENT %length; %facetModel;> <!ATTLIST %length; %facetAttr; %fixedAttr; %lengthAttrs;> <!ELEMENT %minLength; %facetModel;> <!ATTLIST %minLength; %facetAttr; %fixedAttr; %minLengthAttrs;> <!ELEMENT %maxLength; %facetModel;> <!ATTLIST %maxLength; %facetAttr; %fixedAttr; %maxLengthAttrs;> <!-- This one can be repeated --> <!ELEMENT %enumeration; %facetModel;> <!ATTLIST %enumeration; %facetAttr; %enumerationAttrs;> <!ELEMENT %whiteSpace; %facetModel;> <!ATTLIST %whiteSpace; %facetAttr; %fixedAttr; %whiteSpaceAttrs;> <!-- This one can be repeated --> <!ELEMENT %pattern; %facetModel;> <!ATTLIST %pattern; %facetAttr; %patternAttrs;> <!ELEMENT %assertion; %facetModel;> <!ATTLIST %assertion; %facetAttr; %assertionAttrs;> <!ELEMENT %explicitTimezone; %facetModel;> <!ATTLIST %explicitTimezone; %facetAttr; %explicitTimezoneAttrs;>
The following, although in the form of a schema document, does not conform to the rules for schema documents defined in this specification. It contains explicit XML representations of the primitive datatypes which need not be declared in a schema document, since they are automatically included in every schema, and indeed must not be declared in a schema document, since it is forbidden to try to derive types with anyAtomicType as the base type definition. It is included here as a form of documentation.
<?xml version='1.0'?> <!DOCTYPE xs:schema SYSTEM "../namespace/XMLSchema.dtd" [ <!-- keep this schema XML1.0 DTD valid --> <!ENTITY % schemaAttrs 'xmlns:hfp CDATA #IMPLIED'> <!ELEMENT hfp:hasFacet EMPTY> <!ATTLIST hfp:hasFacet name NMTOKEN #REQUIRED> <!ELEMENT hfp:hasProperty EMPTY> <!ATTLIST hfp:hasProperty name NMTOKEN #REQUIRED value CDATA #REQUIRED> ]> <xs:schema xmlns:hfp="http://www.w3.org/2001/XMLSchema-hasFacetAndProperty" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xml:lang="en" targetNamespace="http://www.w3.org/2001/XMLSchema"> <xs:annotation> <xs:documentation> This document contains XML elements which look like definitions for the primitive datatypes. These definitions are for information only; the real built-in definitions are magic. </xs:documentation> <xs:documentation> For each built-in datatype in this schema (both primitive and derived) can be uniquely addressed via a URI constructed as follows: 1) the base URI is the URI of the XML Schema namespace 2) the fragment identifier is the name of the datatype For example, to address the int datatype, the URI is: http://www.w3.org/2001/XMLSchema#int Additionally, each facet definition element can be uniquely addressed via a URI constructed as follows: 1) the base URI is the URI of the XML Schema namespace 2) the fragment identifier is the name of the facet For example, to address the maxInclusive facet, the URI is: http://www.w3.org/2001/XMLSchema#maxInclusive Additionally, each facet usage in a built-in datatype definition can be uniquely addressed via a URI constructed as follows: 1) the base URI is the URI of the XML Schema namespace 2) the fragment identifier is the name of the datatype, followed by a period (".") followed by the name of the facet For example, to address the usage of the maxInclusive facet in the definition of int, the URI is: http://www.w3.org/2001/XMLSchema#int.maxInclusive </xs:documentation> </xs:annotation> <xs:simpleType name="string" id="string"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="length"/> <hfp:hasFacet name="minLength"/> <hfp:hasFacet name="maxLength"/> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="false"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#string"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace value="preserve" id="string.whiteSpace"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="boolean" id="boolean"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="false"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="finite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#boolean"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="boolean.whiteSpace"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="float" id="float"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="maxInclusive"/> <hfp:hasFacet name="maxExclusive"/> <hfp:hasFacet name="minInclusive"/> <hfp:hasFacet name="minExclusive"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="partial"/> <hfp:hasProperty name="bounded" value="true"/> <hfp:hasProperty name="cardinality" value="finite"/> <hfp:hasProperty name="numeric" value="true"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#float"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="float.whiteSpace"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="double" id="double"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="maxInclusive"/> <hfp:hasFacet name="maxExclusive"/> <hfp:hasFacet name="minInclusive"/> <hfp:hasFacet name="minExclusive"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="partial"/> <hfp:hasProperty name="bounded" value="true"/> <hfp:hasProperty name="cardinality" value="finite"/> <hfp:hasProperty name="numeric" value="true"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#double"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="double.whiteSpace"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="decimal" id="decimal"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="totalDigits"/> <hfp:hasFacet name="fractionDigits"/> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="maxInclusive"/> <hfp:hasFacet name="maxExclusive"/> <hfp:hasFacet name="minInclusive"/> <hfp:hasFacet name="minExclusive"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="total"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="true"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#decimal"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="decimal.whiteSpace"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="duration" id="duration"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="maxInclusive"/> <hfp:hasFacet name="maxExclusive"/> <hfp:hasFacet name="minInclusive"/> <hfp:hasFacet name="minExclusive"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="partial"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#duration"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="duration.whiteSpace"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="dateTime" id="dateTime"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="maxInclusive"/> <hfp:hasFacet name="maxExclusive"/> <hfp:hasFacet name="minInclusive"/> <hfp:hasFacet name="minExclusive"/> <hfp:hasFacet name="assertions"/> <hfp:hasFacet name="explicitTimezone"/> <hfp:hasProperty name="ordered" value="partial"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#dateTime"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="dateTime.whiteSpace"/> <xs:explicitTimezone value="optional" id="dateTime.explicitTimezone"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="time" id="time"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="maxInclusive"/> <hfp:hasFacet name="maxExclusive"/> <hfp:hasFacet name="minInclusive"/> <hfp:hasFacet name="minExclusive"/> <hfp:hasFacet name="assertions"/> <hfp:hasFacet name="explicitTimezone"/> <hfp:hasProperty name="ordered" value="partial"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#time"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="time.whiteSpace"/> <xs:explicitTimezone value="optional" id="time.explicitTimezone"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="date" id="date"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="maxInclusive"/> <hfp:hasFacet name="maxExclusive"/> <hfp:hasFacet name="minInclusive"/> <hfp:hasFacet name="minExclusive"/> <hfp:hasFacet name="assertions"/> <hfp:hasFacet name="explicitTimezone"/> <hfp:hasProperty name="ordered" value="partial"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#date"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="date.whiteSpace"/> <xs:explicitTimezone value="optional" id="date.explicitTimezone"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="gYearMonth" id="gYearMonth"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="maxInclusive"/> <hfp:hasFacet name="maxExclusive"/> <hfp:hasFacet name="minInclusive"/> <hfp:hasFacet name="minExclusive"/> <hfp:hasFacet name="assertions"/> <hfp:hasFacet name="explicitTimezone"/> <hfp:hasProperty name="ordered" value="partial"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#gYearMonth"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="gYearMonth.whiteSpace"/> <xs:explicitTimezone value="optional" id="gYearMonth.explicitTimezone"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="gYear" id="gYear"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="maxInclusive"/> <hfp:hasFacet name="maxExclusive"/> <hfp:hasFacet name="minInclusive"/> <hfp:hasFacet name="minExclusive"/> <hfp:hasFacet name="assertions"/> <hfp:hasFacet name="explicitTimezone"/> <hfp:hasProperty name="ordered" value="partial"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#gYear"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="gYear.whiteSpace"/> <xs:explicitTimezone value="optional" id="gYear.explicitTimezone"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="gMonthDay" id="gMonthDay"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="maxInclusive"/> <hfp:hasFacet name="maxExclusive"/> <hfp:hasFacet name="minInclusive"/> <hfp:hasFacet name="minExclusive"/> <hfp:hasFacet name="assertions"/> <hfp:hasFacet name="explicitTimezone"/> <hfp:hasProperty name="ordered" value="partial"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#gMonthDay"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="gMonthDay.whiteSpace"/> <xs:explicitTimezone value="optional" id="gMonthDay.explicitTimezone"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="gDay" id="gDay"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="maxInclusive"/> <hfp:hasFacet name="maxExclusive"/> <hfp:hasFacet name="minInclusive"/> <hfp:hasFacet name="minExclusive"/> <hfp:hasFacet name="assertions"/> <hfp:hasFacet name="explicitTimezone"/> <hfp:hasProperty name="ordered" value="partial"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#gDay"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="gDay.whiteSpace"/> <xs:explicitTimezone value="optional" id="gDay.explicitTimezone"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="gMonth" id="gMonth"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="maxInclusive"/> <hfp:hasFacet name="maxExclusive"/> <hfp:hasFacet name="minInclusive"/> <hfp:hasFacet name="minExclusive"/> <hfp:hasFacet name="assertions"/> <hfp:hasFacet name="explicitTimezone"/> <hfp:hasProperty name="ordered" value="partial"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#gMonth"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="gMonth.whiteSpace"/> <xs:explicitTimezone value="optional" id="gMonth.explicitTimezone"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="hexBinary" id="hexBinary"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="length"/> <hfp:hasFacet name="minLength"/> <hfp:hasFacet name="maxLength"/> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="false"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#hexBinary"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="hexBinary.whiteSpace"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="base64Binary" id="base64Binary"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="length"/> <hfp:hasFacet name="minLength"/> <hfp:hasFacet name="maxLength"/> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="false"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#base64Binary"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="base64Binary.whiteSpace"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="anyURI" id="anyURI"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="length"/> <hfp:hasFacet name="minLength"/> <hfp:hasFacet name="maxLength"/> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="false"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#anyURI"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="anyURI.whiteSpace"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="QName" id="QName"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="length"/> <hfp:hasFacet name="minLength"/> <hfp:hasFacet name="maxLength"/> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="false"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#QName"/> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="QName.whiteSpace"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="NOTATION" id="NOTATION"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="length"/> <hfp:hasFacet name="minLength"/> <hfp:hasFacet name="maxLength"/> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="false"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#NOTATION"/> <xs:documentation> NOTATION cannot be used directly in a schema; rather a type must be derived from it by specifying at least one enumeration facet whose value is the name of a NOTATION declared in the schema. </xs:documentation> </xs:annotation> <xs:restriction base="xs:anyAtomicType"> <xs:whiteSpace fixed="true" value="collapse" id="NOTATION.whiteSpace"/> </xs:restriction> </xs:simpleType> </xs:schema>
The following, although in the form of a schema document, contains XML representations of components already present in all schemas by definition. It is included here as a form of documentation.
Issue (B-1933):It is an open question whether this and similar XML documents should be accepted or rejected by software conforming to this specification. The XML Schema Working Group expects to resolve this question in connection with its work on issues relating to schema composition.In the meantime, some existing schema processors will accept declarations for them; other existing processors will reject such declarations as duplicates.
<?xml version='1.0'?> <!DOCTYPE xs:schema SYSTEM "../namespace/XMLSchema.dtd" [ <!-- keep this schema XML1.0 DTD valid --> <!ENTITY % schemaAttrs 'xmlns:hfp CDATA #IMPLIED'> <!ELEMENT hfp:hasFacet EMPTY> <!ATTLIST hfp:hasFacet name NMTOKEN #REQUIRED> <!ELEMENT hfp:hasProperty EMPTY> <!ATTLIST hfp:hasProperty name NMTOKEN #REQUIRED value CDATA #REQUIRED> ]> <xs:schema xmlns:hfp="http://www.w3.org/2001/XMLSchema-hasFacetAndProperty" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xml:lang="en" targetNamespace="http://www.w3.org/2001/XMLSchema"> <xs:annotation> <xs:documentation> This document contains XML representations for the ordinary non-primitive built-in datatypes </xs:documentation> </xs:annotation> <xs:simpleType name="normalizedString" id="normalizedString"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#normalizedString"/> </xs:annotation> <xs:restriction base="xs:string"> <xs:whiteSpace value="replace" id="normalizedString.whiteSpace"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="token" id="token"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#token"/> </xs:annotation> <xs:restriction base="xs:normalizedString"> <xs:whiteSpace value="collapse" id="token.whiteSpace"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="language" id="language"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#language"/> </xs:annotation> <xs:restriction base="xs:token"> <xs:pattern value="[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*" id="language.pattern"> <xs:annotation> <xs:documentation source="http://www.ietf.org/rfc/bcp/bcp47.txt"> pattern specifies the content of section 2.12 of XML 1.0e2 and RFC 3066 (Revised version of RFC 1766). N.B. RFC 3066 is now obsolete; the grammar of RFC4646 is more restrictive. So strict conformance to the rules for language codes requires extra checking beyond validation against this type. </xs:documentation> </xs:annotation> </xs:pattern> </xs:restriction> </xs:simpleType> <xs:simpleType name="IDREFS" id="IDREFS"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="length"/> <hfp:hasFacet name="minLength"/> <hfp:hasFacet name="maxLength"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="false"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#IDREFS"/> </xs:annotation> <xs:restriction> <xs:simpleType> <xs:list itemType="xs:IDREF"/> </xs:simpleType> <xs:minLength value="1" id="IDREFS.minLength"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="ENTITIES" id="ENTITIES"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="length"/> <hfp:hasFacet name="minLength"/> <hfp:hasFacet name="maxLength"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="false"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#ENTITIES"/> </xs:annotation> <xs:restriction> <xs:simpleType> <xs:list itemType="xs:ENTITY"/> </xs:simpleType> <xs:minLength value="1" id="ENTITIES.minLength"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="NMTOKEN" id="NMTOKEN"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#NMTOKEN"/> </xs:annotation> <xs:restriction base="xs:token"> <xs:pattern value="\c+" id="NMTOKEN.pattern"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/REC-xml#NT-Nmtoken"> pattern matches production 7 from the XML spec </xs:documentation> </xs:annotation> </xs:pattern> </xs:restriction> </xs:simpleType> <xs:simpleType name="NMTOKENS" id="NMTOKENS"> <xs:annotation> <xs:appinfo> <hfp:hasFacet name="length"/> <hfp:hasFacet name="minLength"/> <hfp:hasFacet name="maxLength"/> <hfp:hasFacet name="enumeration"/> <hfp:hasFacet name="whiteSpace"/> <hfp:hasFacet name="pattern"/> <hfp:hasFacet name="assertions"/> <hfp:hasProperty name="ordered" value="false"/> <hfp:hasProperty name="bounded" value="false"/> <hfp:hasProperty name="cardinality" value="countably infinite"/> <hfp:hasProperty name="numeric" value="false"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#NMTOKENS"/> </xs:annotation> <xs:restriction> <xs:simpleType> <xs:list itemType="xs:NMTOKEN"/> </xs:simpleType> <xs:minLength value="1" id="NMTOKENS.minLength"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="Name" id="Name"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#Name"/> </xs:annotation> <xs:restriction base="xs:token"> <xs:pattern value="\i\c*" id="Name.pattern"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/REC-xml#NT-Name"> pattern matches production 5 from the XML spec </xs:documentation> </xs:annotation> </xs:pattern> </xs:restriction> </xs:simpleType> <xs:simpleType name="NCName" id="NCName"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#NCName"/> </xs:annotation> <xs:restriction base="xs:Name"> <xs:pattern value="[\i-[:]][\c-[:]]*" id="NCName.pattern"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/REC-xml-names/#NT-NCName"> pattern matches production 4 from the Namespaces in XML spec </xs:documentation> </xs:annotation> </xs:pattern> </xs:restriction> </xs:simpleType> <xs:simpleType name="ID" id="ID"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#ID"/> </xs:annotation> <xs:restriction base="xs:NCName"/> </xs:simpleType> <xs:simpleType name="IDREF" id="IDREF"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#IDREF"/> </xs:annotation> <xs:restriction base="xs:NCName"/> </xs:simpleType> <xs:simpleType name="ENTITY" id="ENTITY"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#ENTITY"/> </xs:annotation> <xs:restriction base="xs:NCName"/> </xs:simpleType> <xs:simpleType name="integer" id="integer"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#integer"/> </xs:annotation> <xs:restriction base="xs:decimal"> <xs:fractionDigits fixed="true" value="0" id="integer.fractionDigits"/> <xs:pattern value="[\-+]?[0-9]+" id="integer.pattern"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="nonPositiveInteger" id="nonPositiveInteger"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#nonPositiveInteger"/> </xs:annotation> <xs:restriction base="xs:integer"> <xs:maxInclusive value="0" id="nonPositiveInteger.maxInclusive"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="negativeInteger" id="negativeInteger"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#negativeInteger"/> </xs:annotation> <xs:restriction base="xs:nonPositiveInteger"> <xs:maxInclusive value="-1" id="negativeInteger.maxInclusive"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="long" id="long"> <xs:annotation> <xs:appinfo> <hfp:hasProperty name="bounded" value="true"/> <hfp:hasProperty name="cardinality" value="finite"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#long"/> </xs:annotation> <xs:restriction base="xs:integer"> <xs:minInclusive value="-9223372036854775808" id="long.minInclusive"/> <xs:maxInclusive value="9223372036854775807" id="long.maxInclusive"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="int" id="int"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#int"/> </xs:annotation> <xs:restriction base="xs:long"> <xs:minInclusive value="-2147483648" id="int.minInclusive"/> <xs:maxInclusive value="2147483647" id="int.maxInclusive"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="short" id="short"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#short"/> </xs:annotation> <xs:restriction base="xs:int"> <xs:minInclusive value="-32768" id="short.minInclusive"/> <xs:maxInclusive value="32767" id="short.maxInclusive"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="byte" id="byte"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#byte"/> </xs:annotation> <xs:restriction base="xs:short"> <xs:minInclusive value="-128" id="byte.minInclusive"/> <xs:maxInclusive value="127" id="byte.maxInclusive"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="nonNegativeInteger" id="nonNegativeInteger"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#nonNegativeInteger"/> </xs:annotation> <xs:restriction base="xs:integer"> <xs:minInclusive value="0" id="nonNegativeInteger.minInclusive"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="unsignedLong" id="unsignedLong"> <xs:annotation> <xs:appinfo> <hfp:hasProperty name="bounded" value="true"/> <hfp:hasProperty name="cardinality" value="finite"/> </xs:appinfo> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#unsignedLong"/> </xs:annotation> <xs:restriction base="xs:nonNegativeInteger"> <xs:maxInclusive value="18446744073709551615" id="unsignedLong.maxInclusive"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="unsignedInt" id="unsignedInt"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#unsignedInt"/> </xs:annotation> <xs:restriction base="xs:unsignedLong"> <xs:maxInclusive value="4294967295" id="unsignedInt.maxInclusive"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="unsignedShort" id="unsignedShort"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#unsignedShort"/> </xs:annotation> <xs:restriction base="xs:unsignedInt"> <xs:maxInclusive value="65535" id="unsignedShort.maxInclusive"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="unsignedByte" id="unsignedByte"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#unsignedByte"/> </xs:annotation> <xs:restriction base="xs:unsignedShort"> <xs:maxInclusive value="255" id="unsignedByte.maxInclusive"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="positiveInteger" id="positiveInteger"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#positiveInteger"/> </xs:annotation> <xs:restriction base="xs:nonNegativeInteger"> <xs:minInclusive value="1" id="positiveInteger.minInclusive"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="yearMonthDuration"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#yearMonthDuration"> This type includes just those durations expressed in years and months. Since the pattern given excludes days, hours, minutes, and seconds, the values of this type have a seconds property of zero. They are totally ordered. </xs:documentation> </xs:annotation> <xs:restriction base="xs:duration"> <xs:pattern id="yearMonthDuration.pattern" value="[^DT]*"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="dayTimeDuration"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#dayTimeDuration"> This type includes just those durations expressed in days, hours, minutes, and seconds. The pattern given excludes years and months, so the values of this type have a months property of zero. They are totally ordered. </xs:documentation> </xs:annotation> <xs:restriction base="xs:duration"> <xs:pattern id="dayTimeDuration.pattern" value="[^YM]*(T.*)?"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="dateTimeStamp" id="dateTimeStamp"> <xs:annotation> <xs:documentation source="http://www.w3.org/TR/xmlschema11-2/#dateTimeStamp"> This datatype includes just those dateTime values Whose explicitTimezone is present. They are totally ordered. </xs:documentation> </xs:annotation> <xs:restriction base="xs:dateTime"> <xs:explicitTimezone fixed="true" id="dateTimeStamp.explicitTimezone" value="required"/> </xs:restriction> </xs:simpleType> </xs:schema>
Some datatypes, such as integer, describe well-known mathematically abstract systems. Others, such as the date/time datatypes, describe "real-life", "applied" systems. Certain of the systems described by datatypes, both abstract and applied, have values in their value spaces most easily described as things having several properties, which in turn have values which are in some sense "primitive" or are from the value spaces of simpler datatypes.
In this document, the arguments to functions are assumed to be "call by value" unless explicitly noted to the contrary, meaning that if the argument is modified during the processing of the algorithm, that modification is not reflected in the "outside world". On the other hand, the arguments to procedures are assumed to be "call by location", meaning that modifications are so reflected, since that is the only way the processing of the algorithm can have any effect.
Properties always have values. [Definition:] An optional property is permitted but not required to have the distinguished value absent.
[Definition:] Throughout this specification, the value absent is used as a distinguished value to indicate that a given instance of a property "has no value" or "is absent". This should not be interpreted as constraining implementations, as for instance between using a null value for such properties or not representing them at all.
e
' | 'E
') noDecimalPtNumeralThere are several different primitive but related datatypes defined in the specification which pertain to various combinations of dates and times, and parts thereof. They all use related value-space models, which are described in detail in this section. It is not difficult for a casual reader of the descriptions of the individual datatypes elsewhere in this specification to misunderstand some of the details of just what the datatypes are intended to represent, so more detail is presented here in this section.
All of the value spaces for dates and times described here represent moments or periods of time in Universal Coordinated Time (UTC). [Definition:] Universal Coordinated Time (UTC) is an adaptation of TAI which closely approximates UT1 by adding ·leap-seconds· to selected ·UTC· days.
[Definition:] A leap-second is an additional second added to the last day of December, June, October, or March, when such an adjustment is deemed necessary by the International Earth Rotation and Reference Systems Service in order to keep ·UTC· within 0.9 seconds of observed astronomical time. When leap seconds are introduced, the last minute in the day has more than sixty seconds. In theory leap seconds can also be removed from a day, but this has not yet occurred. (See [International Earth Rotation Service (IERS)], [ITU-R TF.460-6].) Leap seconds are not supported by the types defined here.
Because the dateTime type and other date- and time-related types defined in this specification do not support leap seconds, there are portions of the ·UTC· timeline which cannot be represented by values of these types. Users whose applications require that leap seconds be represented and that date/time arithmetic take historically occurring leap seconds into account will wish to make appropriate adjustments at the application level, or to use other types.
There are two distinct ways to model moments in time: either by tracking their year, month, day, hour, minute and second (with fractional seconds as needed), or by tracking their time (measured generally in seconds or days) from some starting moment. Each has its advantages. The two are isomorphic. For definiteness, we choose to model the first using five integer and one decimal number properties. We superimpose the second by providing one decimal number-valued function which gives the corresponding count of seconds from zero (the "time on the time line").
Non-negative values of the properties map to the years, months, days of month, etc. of the Gregorian calendar in the obvious way. Values less than 1582 in the ·year· property represent years in the "proleptic Gregorian calendar". A value of zero in the ·year· property represents the year 1 BCE; a value of −1 represents the year 2 BCE, −2 is 3 BCE, etc.
The model just described is called herein the "seven-property" model for date/time datatypes. It is used "as is" for dateTime; all other date/time datatypes except duration use the same model except that some of the six primary properties are required to have the value absent, instead of being required to have a numerical value. (An ·optional· property, like ·timezoneOffset·, is always permitted to have the value absent.)
·timezoneOffset· values are limited to 14 hours, which is 840 (= 60 × 14) minutes.
Readers interested in when leap-seconds have been introduced should consult [USNO Historical List], which includes a list of times when the difference between TAI and ·UTC· has changed. Because the simple types defined here do not support leap seconds, they cannot be used to represent the final second, in ·UTC·, of any of the days containing one. If it is important, at the application level, to track the occurrence of leap seconds, then users will need to make special arrangements for special handling of them and of time intervals crossing them.
While calculating, property values from the dateTime 1972-12-31T00:00:00 are used to fill in for those that are absent, except that if ·day· is absent but ·month· is not, the largest permitted day for that month is used.