home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeXML SchemaSearch this book

Chapter 16. Datatype Reference Guide

Contents:

Datatypes

This chapter provides a quick reference to all of the datatypes W3C XML Schema defines. Each datatype is listed with its constraining facets, as well as information about what it represents and how.

16.1. Datatypes

xs:anyURIURI (Uniform Resource Identifier).

<xs:simpleType name="anyURI" id="anyURI">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction></xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:anyURI

Known subtypes:

none

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

This datatype corresponds normatively to the XLink href attribute. Its value space includes the URIs defined by the RFCs 2396 and 2732, but its lexical space doesn't require the character escapes needed to include non-ASCII characters in URIs.

Restrictions

Relative URIs are not "absolutized" by W3C XML Schema. A datatype defined as:

<xs:simpleType name="schemaRecommendations">
  <xs:restriction base="xs:anyURI">
    <xs:enumeration value="http://www.w3.org/TR/xmlschema-0/"/>
    <xs:enumeration value="http://www.w3.org/TR/xmlschema-1/"/>
    <xs:enumeration value="http://www.w3.org/TR/xmlschema-2/"/>
  </xs:restriction> 
</xs:simpleType>

should not validate the href attribute in this instance element:

<a xml:base="http://www.w3.org/TR/" href="xmlschema-1/">
  XML Schema Part 2: Datatypes
</a> 

The Recommendation states that "it is impractical for processors to check that a value is a context-appropriate URI reference," freeing schema processors from having to validate the correctness of the URI.

Example

<xs:simpleType name="httpURI">
  <xs:restriction base="xs:anyURI">
    <xs:pattern value="http://.*"/>
  </xs:restriction>
</xs:simpleType>
xs:base64BinaryBinary content coded as "base64".

<xs:simpleType name="base64Binary" id="base64Binary">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:base64Binary

Known subtypes:

none

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

The value space of xs:base64Binary is the set of arbitrary binary contents. Its lexical space is the same set after base64 coding. This coding is described in Section 6.8 of RFC 2045.

Restrictions

RFC 2045 has been defined to transfer binary contents over text-based mail systems. It imposes a line break at least every 76 characters to avoid the inclusion of arbitrary line breaks by the mail systems. Sending base64 content without line breaks is nevertheless a common usage for applications such as SOAP and the W3C XML Schema Working Group. After a request from other W3C Working Groups, the W3C XML Schema Working Group decided to remove the obligation to include these line breaks from the constraints on the lexical space. (This decision was made after the publication of the W3C XML Schema Recommendation and should be included in a release of the errata.)

Example

<xs:element name="picture">
  <xs:complexType>
    <xs:simpleContent>
      <xs:extension base="xs:base64Binary">
        <xs:attribute name="type" type="graphicalFormat"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>
</xs:element>
xs:booleanBoolean (true or false).

<xs:simpleType name="boolean" id="boolean">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:boolean

Known subtypes:

none

Facets:

xs:pattern, xs:whiteSpace

Description

The value space of xs:boolean is "true" and "false," and its lexical space accepts true, false, and also "1" (for true) and "0" (for false).

Restrictions

This datatype cannot be localized--for instance, to accept "vrai" and "faux" instead of "true" and "false".

Example

<book id="b0836217462" available="true"/>
xs:byteSigned value of 8 bits.

<xs:simpleType name="byte" id="byte">
  <xs:restriction base="xs:short">
    <xs:minInclusive value="-128"/>
    <xs:maxInclusive value="127"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:short

Primary:

xs:decimal

Known subtypes:

none

Facets:

xs:enumeration, xs:fractionDigits, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:totalDigits, xs:whiteSpace

Description

The value space of xs:byte is the integers between -128 and 127, i.e., the signed values that can fit in a word of 8 bits. Its lexical space allows an optional sign and leading zeros before the significant digits.

Restrictions

The lexical space does not allow values expressed in other numeration bases (such as hexadecimal, octal, or binary).

Example

Valid values for byte include 27, -34, +105, and 0.

Invalid values include 0A, 1524, and INF.

xs:dateGregorian calendar date.

<xs:simpleType name="date" id="date">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:date

Known subtypes:

none

Facets:

xs:enumeration, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:whiteSpace

Description

This datatype is modeled after the calendar dates defined in Chapter 5.2.1 of ISO 8601. Its value space is the set of Gregorian calendar dates as defined by this standard; i.e., a one-day-long period of time. Its lexical space is the ISO 8601 extended format "[-]CCYY-MM-DD[Z|(+|-)hh:mm]" with an optional timezone. Timezones that are not specified are considered "undetermined."

Restrictions

The basic format of ISO 8601 calendar dates "CCYYMMDD" is not supported.

The other forms of dates available in ISO 8601--ordinal dates defined by the year and the number of the day in the year and dates identified by calendar week and day numbers--are not supported.

As the value space is defined by reference to ISO 8601, there is no support for any calendar system other than Gregorian.

As the lexical space is also defined as reference to ISO 8601, there is no support for any localization such as different orders for date parts or named months.

The order relation between dates with and without timezone is partial: they can be compared only outside of a +/- 14 hours interval.

There is a dissension between ISO 8601 which defines a day as a period of time of 24 hours, and W3C XML Schema, which indicates that a date is a "one-day long, non-periodic instance . . . independent of how many hours this day has." Even though technically right (some days do not last exactly 24 hours because of leap seconds), this definition is not coherent with the definition of xs:duration for which a day is always exactly 24 hours long.

Example

Valid values include: "2001-10-26", "2001-10-26+02:00", "2001-10-26Z", "2001-10-26+00:00", "-2001-10-26", or "-20000-04-01".

The following values would be invalid: "2001-10" (all the parts must be specified), "2001-10-32" (the days part (32) is out of range), "2001-13-26+02:00" (the month part (13) is out of range), or "01-10-26" (the century part is missing).

xs:dateTimeInstant of time (Gregorian calendar).

<xs:simpleType name="dateTime" id="dateTime">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:dateTime

Known subtypes:

none

Facets:

xs:enumeration, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:whiteSpace

Description

This datatype describes instants identified by the combination of a date and a time. Its value space is described as a "combination of date and time of day" in Chapter 5.4 of ISO 8601. Its lexical space is the extended format "[-]CCYY-MM-DDThh:mm:ss[Z|(+|-)hh:mm]". The timezone may be specified as "Z" (UTC) or "(+|-)hh:mm." Timezones that are not specified are considered "undetermined."

Restrictions

The basic format of ISO 8601 calendar datetimes "CCYYMMDDThhmmss" is not supported.

The other forms of datetimes available in ISO 8601--ordinal dates defined by the year and the number of the day in the year and dates identified by calendar week and day numbers--are not supported.

As the value space is defined by reference to ISO 8601, there is no support for any calendar system other than Gregorian.

As the lexical space is also defined as reference to ISO 8601, there is no support for any localization such as different orders for date parts or named months.

The order relation between datetimes with and without timezone is partial: they can be compared only outside of a +/- 14 hours interval.

Example

Valid values for xs:dateTime include: "2001-10-26T21:32:52", "2001-10-26T21:32:52+02:00", "2001-10-26T19:32:52Z", "2001-10-26T19:32:52+00:00", "-2001-10-26T21:32:52", or "2001-10-26T21:32:52.12679".

The following values would be invalid: "2001-10-26" (all the parts must be specified), "2001-10-26T21:32" (all the parts must be specified), "2001-10-26T25:32:52+02:00" (the hours part (25) is out of range), or "01-10-26T21:32" (all the parts must be specified).

xs:decimalDecimal numbers.

<xs:simpleType name="decimal" id="decimal">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:decimal

Known subtypes:

xs:integer

Facets:

xs:enumeration, xs:fractionDigits, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:totalDigits, xs:whiteSpace

Description

xs:decimal is the datatype that represents the set of all the decimal numbers with arbitrary lengths. Its lexical space allows any number of insignificant leading and trailing zeros (after the decimal point).

Restrictions

The decimal separator is always a point (".") and no thousand separator may be added. There is no support for scientific notations.

Example

Valid values include: "123.456", "+1234.456", "-1234.456", "-.456", or "-456".

The following values would be invalid: "1 234.456" (spaces are forbidden), "1234.456E+2" (scientific notation ("E+2") is forbidden), "+ 1234.456" (spaces are forbidden), or "+1,234.456" (delimiters between thousands are forbidden).

xs:doubleIEEE 64 bit floating point.

<xs:simpleType name="double" id="double">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:double

Known subtypes:

none

Facets:

xs:enumeration, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:whiteSpace

Description

The value space of xs:double is "double" (64 bits) floating-point numbers as defined by the IEEE. The lexical space uses a decimal format with optional scientific notation. The match between lexical (powers of 10) and value (powers of 2) spaces is approximate and done on the closest value.

This datatype differentiates positive (0) and negative (-0) zeros, and includes the special values "-INF" (negative infinity), "INF" (positive infinity) and "NaN" (Not a Number).

Note that the lexical spaces of xs:float and xs:double are exactly the same; the only difference is the precision used to convert the values in the value space.

Restrictions

The decimal separator is always a point (".") and no thousands separator may be used.

Examples

Valid values include: "123.456", "+1234.456", "-1.2344e56", "-.45E-6", "INF", "-INF", or "NaN".

The following values would be invalid: "1234.4E 56" (spaces are forbidden), "1E+2.5" (the power of 10 must be an integer), "+INF" (positive infinity doesn't expect a sign), or "NAN" (capitalization matters in special values).

xs:durationTime durations.

<xs:simpleType name="duration" id="duration">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:duration

Known subtypes:

none

Facets:

xs:enumeration, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:whiteSpace

Description

Durations may be expressed using all the parts of a datetime (from year to fractions of second) and are, therefore, defined as a "six-dimensional space." Note that because the relation between some of these date parts (such as the number of days in a month) is not fixed, the order relationship between durations is only partial and the result of a comparison between two durations may be undetermined.

The lexical space of xs:duration is the format defined by ISO 8601 under the form "PnYnMnDTnHnMnS," in which the capital letters are delimiters and can be omitted when the corresponding member is not used.

Although some durations are undetermined, this is fixed as soon as a starting point is fixed for the duration. W3C XML Schema relies on this feature to define the algorithm to use to compare two durations. Four datetimes have been chosen, which produce the greatest deviations when durations are added. A duration will be considered bigger than another when the result of its addition to these four dates is consistently bigger than the result of the addition of the other duration to these same four datetimes. These datetimes are: "1696-09-01T00:00:00Z", "1697-02-01T00:00:00Z," "1903-03-01T00:00:00Z," and "1903-07-01T00:00:00Z."

Restrictions

The lexical space cannot be customized.

Example

Valid values include "PT1004199059S", "PT130S", "PT2M10S", "P1DT2S", "-P1Y", or "P1Y2M3DT5H20M30.123S".

The following values would be invalid: "1Y" (leading "P" is missing), "P1S" ("T" separator is missing), "P-1Y" (all parts must be positive), "P1M2Y" (parts order is significant and Y must precede M), or "P1Y-1M" (all parts must be positive).

xs:ENTITIESWhitespace separated list of unparsed entity references.

<xs:simpleType name="ENTITIES" id="ENTITIES">
  <xs:restriction>
    <xs:simpleType>
      <xs:list>
        <xs:simpleType>
          <xs:restriction base="xs:ENTITY"/>
        </xs:simpleType>
      </xs:list>
    </xs:simpleType>
    <xs:minLength value="1"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:ENTITY

Primary:

none

Known subtypes:

none

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:whiteSpace

Description

xs:ENTITIES is derived by a list from xs:ENTITY. It represents lists of unparsed entity references. Each part of this entity reference is a nonqualified name (xs:NCName) and must be declared as an unparsed entity in an internal or external DTD.

Restrictions

Unparsed entities have been defined in XML 1.0 as a way to include non-XML content in a XML document, but most of the applications prefer to define links (such as those defined in (X)HTML to include images or other multimedia objects).

W3C XML Schema does not provide alternative ways to declare unparsed entities. A DTD is needed to do so.

xs:ENTITYReference to an unparsed entity.

<xs:simpleType name="ENTITY" id="ENTITY">
  <xs:restriction base="xs:NCName"/>
</xs:simpleType>

Derived from:

xs:NCName

Primary:

xs:string

Known subtypes:

xs:ENTITIES

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

xs:ENTITY is an entity reference, i.e., a nonqualified name (xs:NCName) that has been declared as an unparsed entity in an internal or external DTD.

Restrictions

Unparsed entities are defined in XML 1.0 as a way to include non-XML content in XML document, but most of the applications prefer to define links (such as those defined in (X)HTML to include images or other multimedia objects).

W3C XML Schema does not provide alternative ways to declare unparsed entities. A DTD is needed to do so.

xs:floatIEEE 32 bit floating point.

<xs:simpleType name="float" id="float">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:float

Known subtypes:

none

Facets:

xs:enumeration, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:whiteSpace

Description

The value space of xs:float is "float" (32 bits) floating-point numbers as defined by the IEEE. The lexical space uses a decimal format with optional scientific notation. The match between lexical (powers of 10) and value (powers of 2) spaces is approximate and is done on the closest value.

This datatype differentiates positive (0) and negative (-0) zeros, and includes the special values "-INF" (negative infinity), "INF" (positive infinity), and "NaN" (Not a Number).

Note that the lexical spaces of xs:float and xs:double are exactly the same; the only difference is the precision used to convert the values in the value space.

Restrictions

The decimal separator is always a point (".") and no thousands separator may be added.

Example

Valid values include: "123.456", "+1234.456", "-1.2344e56", "-.45E-6", "INF", "-INF", or "NaN".

The following values would be invalid: "1234.4E 56" (spaces are forbidden), "1E+2.5" (the power of 10 must be an integer), "+INF" (positive infinity doesn't expect a sign), or "NAN" (capitalization matters in special values).

xs:gDayRecurring period of time: monthly day.

<xs:simpleType name="gDay" id="gDay">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:gDay

Known subtypes:

none

Facets:

xs:enumeration, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:whiteSpace

Description

The value space of xs:gDay is the periods of one calendar day recurring each calendar month (such as the third of the month); its lexical space follows the ISO 8601 syntax for such periods (i.e., " -- -DD") with an optional timezone.

When needed, days are reduced to fit in the length of the months, so ---31 would occur on the the 28th of February of nonleap years.

Restrictions

The period (one month) and the duration (one day) are fixed, and no calendars other than the Gregorian are supported.

Example

Valid values include "---01", "---01Z", "---01+02:00", "---01-04:00", "---15", or "---31".

The following values would be invalid: "--30-" (the format must be "---DD"), "---35" (the day is out of range), "---5" (all the digits must be supplied), or "15" (missing leading "---").

xs:gMonthRecurring period of time: yearly month.

<xs:simpleType name="gMonth" id="gMonth">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:gMonth

Known subtypes:

none

Facets:

xs:enumeration, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:whiteSpace

Description

The value space of xs:gMonth is the period of one calendar month recurring each calendar year (such as the month of April); its lexical space should follow the ISO 8601 syntax for such periods (i.e., " -- MM") with an optional timezone. However, there is a typo in the W3C XML Schema Recommendation where the format is defined as " -- MM -- -- . Even though an erratum should be published to bring the W3C XML Schema inline with ISO 8601, most of the current schema processors will expect the (bogus) format " -- MM -- -- . In the example, we follow the correct ISO 8601 format.

Restrictions

The period (one year) and the duration (one month) are fixed, and no calendars other than the Gregorian are supported.

Because of the typo in the W3C XML Schema Specification, users must choose between a bogus format, which works on the current version of the tools, or a correct format, which conforms to ISO 8601.

Example

Valid values include "--05", "--11Z", "--11+02:00", "--11-04:00", or "--02".

The following values would be invalid: "-01-" (the format must be "--MM"), "--13" (the month is out of range), "--1" (both digits must be provided), or "01" (leading " -- " are missing).

xs:gMonthDayRecurring period of time: yearly day.

<xs:simpleType name="gMonthDay" id="gMonthDay">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:gMonthDay

Known subtypes:

none

Facets:

xs:enumeration, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:whiteSpace

Description

The value space of xs:gMonthDay is the period of one calendar day recurring each calendar year (such as the third of April); its lexical space follows the ISO 8601 syntax for such periods (i.e., " -- MM-DD") with an optional timezone.

When needed, days are reduced to fit in the length of the months, so --02-29 would occur on the the 28th of February of nonleap years.

Restrictions

The period (one year) and the duration (one day) are fixed, and no calendars other than the Gregorian are supported.

Example

Valid values include "--05-01", "--11-01Z", "--11-01+02:00", "--11-01-04:00", "--11-15", or "--02-29".

The following values would be invalid: "-01-30-" (the format must be "--MM-DD"), "--01-35" (the day part is out of range), "--1-5" (the leading zeros are missing), or "01-15" (the leading "--" are missing).

xs:gYearPeriod of one year.

<xs:simpleType name="gYear" id="gYear">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:gYear

Known subtypes:

none

Facets:

xs:enumeration, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:whiteSpace

Description

The value space of xs:gYear is the period of one calendar year (such as the year 2002); its lexical space follows the ISO 8601 syntax for such periods (i.e., "YYYY") with an optional timezone.

Restrictions

The duration (one year) is fixed, and no calendars other than the Gregorian are supported.

Example

Valid values include "2001", "2001+02:00", "2001Z", "2001+00:00", "-2001", or "-20000".

The following values would be invalid: "01" (the century part is missing) or "2001-12" (month parts are forbidden).

xs:gYearMonthPeriod of one month.

<xs:simpleType name="gYearMonth" id="gYearMonth">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:gYearMonth

Known subtypes:

none

Facets:

xs:enumeration, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:whiteSpace

Description

The value space of xs:gYearMonth is the period of one calendar month (such as the month of February 2002); its lexical space follows the ISO 8601 syntax for such periods (i.e., "YYYY-MM") with an optional timezone.

Restrictions

The duration (one month) is fixed, and no calendars other than the Gregorian are supported.

Example

Valid values include "2001-10", "2001-10+02:00", "2001-10Z", "2001-10+00:00", "-2001-10", or "-20000-04".

The following values would be invalid: "2001" (the month part is missing), "2001-13" (the month part is out of range), "2001-13-26+02:00" (the month part is out of range), or "01-10" (the century part is missing).

xs:hexBinaryBinary contents coded in hexadecimal.

<xs:simpleType name="hexBinary" id="hexBinary">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:hexBinary

Known subtypes:

none

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

The value space of xs:hexBinary is the set of all binary contents; its lexical space is a simple coding of each octet as its hexadecimal value.

Restrictions

This datatype should not be confused with another encoding called BinHex that is not supported by W3C XML Schema. Other popular binary text encodings (such as uuXXcode, Quote Printable, BinHex, aencode, or base85, to name few) are not supported by the W3C XML Schema.

The expansion factor is high since each binary octet is coded as two characters (i.e., four octets if the document is encoded with UTF-16).

Example

A UTF-8 XML header such as:

"<?xml version="1.0" encoding="UTF-8"?>"

encoded would be:

"3f3c6d78206c657673726f693d6e3122302e20226e656f636964676e223d54552d4622383e3f"
xs:IDDefinition of unique identifiers.

<xs:simpleType name="ID" id="ID">
  <xs:restriction base="xs:NCName"/>
</xs:simpleType>

Derived from:

xs:NCName

Primary:

xs:string

Known subtypes:

none

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

The purpose of the xs:ID datatype is to define unique identifiers that are global to a document and emulate the ID attribute type available in the XML DTDs.

Unlike their DTD counterparts, W3C XML Schema ID datatypes can be used to define not only attributes, but also simple element content.

For both attributes and simple element content, the lexical domain of these datatypes is the lexical domain of XML nonqualified names (xs:NCName).

Identifiers defined using this datatype are global to a document and provide a way to uniquely identify their containing element, whatever its type and name is.

The constraint added by this datatype beyond the xs:NCName datatype from which it is derived is that the values of all the attributes and elements that have an ID datatype in a document must be unique.

Restrictions

Applications that need to maintain a level of compatibility with DTDs should not use this datatype for elements but should reserve it for attributes.

The lexical domain (xs:NCName) of this datatype doesn't allow the definition of numerical identifiers or identifiers containing whitespaces.

W3C XML Schema provides another mechanism to define unique and key constraints using the xs:unique or xs:key elements when more flexibility is needed.

Example

<xs:element name="book">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="isbn" type="xs:int"/>
      <xs:element name="title" type="xs:string"/>
      <xs:element name="author-ref">
        <xs:complexType>
          <xs:attribute name="ref" type="xs:IDREF" use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="character-refs" type="xs:IDREFS"/>
    </xs:sequence>
    <xs:attribute name="identifier" type="xs:ID" use="required"/>
  </xs:complexType>
</xs:element>
xs:IDREFDefinition of references to unique identifiers.

<xs:simpleType name="IDREF" id="IDREF">
  <xs:restriction base="xs:NCName"/>
</xs:simpleType>

Derived from:

xs:NCName

Primary:

xs:string

Known subtypes:

xs:IDREFS

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

The xs:IDREF datatype defines references to the identifiers defined by the ID datatype and, therefore, emulates the IDREF attribute type of the XML DTDs, even though it can be used for simple content elements as well as for attributes.

The lexical space of xs:IDREF is, like the lexical space of xs:ID, nonqualified XML names (NCName).

The constraint added by this datatype beyond the xs:NCName datatype from which it is derived is the values of all the attributes and elements that have a xs:IDREF datatype must match an ID defined within the same document.

Restrictions

Applications that need to maintain a level of compatibility with DTDs should not use this datatype for elements but should reserve it for attributes.

The lexical domain (NCName) of this datatype doesn't allow definition of numerical key references or references containing whitespaces.

W3C XML Schema provides another mechanism to define key reference constraints using the xs:keyref elements when more flexibility is needed.

Example

<xs:element name="book">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="isbn" type="xs:int"/>
      <xs:element name="title" type="xs:string"/>
      <xs:element name="author-ref">
        <xs:complexType>
          <xs:attribute name="ref" type="xs:IDREF" use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="character-refs" type="xs:IDREFS"/>
    </xs:sequence>
    <xs:attribute name="identifier" type="xs:ID" use="required"/>
  </xs:complexType>
</xs:element>
xs:IDREFSDefinition of lists of references to unique identifiers.

<xs:simpleType name="IDREFS" id="IDREFS">
  <xs:restriction>
    <xs:simpleType>
      <xs:list>
        <xs:simpleType>
          <xs:restriction base="xs:IDREF"/>
        </xs:simpleType>
      </xs:list>
    </xs:simpleType>
    <xs:minLength value="1"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:IDREF

Primary:

none

Known subtypes:

none

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:whiteSpace

Description

xs:IDREFS is derived as a list from xs:IDREF and, thus, represents whitespace-separated lists of references to identifiers defined using the ID datatype.

The lexical space of xs:IDREFS is the lexical space of a list of xs:NCName values with a minimum length of one element (xs:IDREFS cannot be empty lists).

xs:IDREFS emulates the xs:IDREFS attribute type of the XML DTDs, even though it can be used to define simple content elements as well as attributes.

Restrictions

Applications that need to maintain a level of compatibility with DTDs should not use this datatype for elements but should reserve it for attributes.

The lexical domain (lists of xs:NCName) of this datatype doesn't allow definition of lists of numerical key references or references containing whitespaces.

Although the W3C XML Schema provides another mechanism to define unique, key, and key reference constraints (using the xs:unique, xs:key, and xs:keyref elements) when more flexibility is needed, this mechanism doesn't provide any alternative for lists of key references (similar to xs:IDREFS).

Example

<xs:element name="book">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="isbn" type="xs:int"/>
      <xs:element name="title" type="xs:string"/>
      <xs:element name="author-ref">
        <xs:complexType>
          <xs:attribute name="ref" type="xs:IDREF" use="required"/>
        </xs:complexType>
      </xs:element>
      <xs:element name="character-refs" type="xs:IDREFS"/>
    </xs:sequence>
    <xs:attribute name="identifier" type="xs:ID" use="required"/>
  </xs:complexType>
</xs:element>
xs:int32 bit signed integers.

<xs:simpleType name="int" id="int">
  <xs:restriction base="xs:long">
    <xs:minInclusive value="-2147483648"/>
    <xs:maxInclusive value="2147483647"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:long

Primary:

xs:decimal

Known subtypes:

xs:short

Facets:

xs:enumeration, xs:fractionDigits, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:totalDigits, xs:whiteSpace

Description

The value space of xs:int is the set of common single size integers (32 bits), i.e., the integers between -2147483648 and 2147483647, its lexical space allows any number of insignificant leading zeros.

Restrictions

The decimal point (even when followed only by insignificant zeros) is forbidden.

-0 and +0 are considered equal, which is different from the behavior of xs:float and xs:double.

Example

Valid values include "-2147483648", "0", "-0000000000000000000005", or "2147483647".

Invalid values include "-2147483649" and "1".

xs:integerSigned integers of arbitrary length.

<xs:simpleType name="integer" id="integer">
  <xs:restriction base="xs:decimal">
    <xs:fractionDigits value="0" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:decimal

Primary:

xs:decimal

Known subtypes:

xs:nonPositiveInteger, xs:long, xs:nonNegativeInteger

Facets:

xs:enumeration, xs:fractionDigits, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:totalDigits, xs:whiteSpace

Description

The value space of xs:integer includes the set of all the signed integers, with no restriction on range. Its lexical space allows any number of insignificant leading zeros.

Restrictions

The decimal point (even when followed only by insignificant zeros) is forbidden.

-0 and +0 are considered equal, which is different from the behavior of xs:float and xs:double.

Example

Valid values for xs:integer include "-123456789012345678901234567890", "2147483647", "0", or "-0000000000000000000005".

Invalid values include "1.", "2.6", and "A".

xs:languageRFC 1766 language codes.

<xs:simpleType name="language" id="language">
  <xs:restriction base="xs:token">
     <xs:pattern
      value="([a-zA-Z]{2}|[iI]-[a-zA-Z]+|[xX]-[a-zA-Z]{1,8})(-[a-zA-Z]{1,8})*"
      />
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:token

Primary:

xs:string

Known subtypes:

none

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

The lexical and value spaces of xs:language are the set of language codes defined by the RFC 1766.

Restrictions

Although the schema for schema defines a minimal test to perform expressed as patterns (see the Definition), the lexical space is the set of existing language codes.

Example

Some valid values for this datatype are: "en", "en-US", "fr", or "fr-FR".

xs:long64 bit signed integers.

<xs:simpleType name="long" id="long">
  <xs:restriction base="xs:integer">
    <xs:minInclusive value="-9223372036854775808"/>
    <xs:maxInclusive value="9223372036854775807"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:integer

Primary:

xs:decimal

Known subtypes:

xs:int

Facets:

xs:enumeration, xs:fractionDigits, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:totalDigits, xs:whiteSpace

Description

The value space of xs:long is the set of common double-size integers (64 bits), i.e., the integers between -9223372036854775808 and 9223372036854775807; its lexical space allows any number of insignificant leading zeros.

Restrictions

The decimal point (even when followed only by insignificant zeros) is forbidden.

Example

Valid values for xs:long include "-9223372036854775808", "0", "-0000000000000000000005", or "9223372036854775807".

Invalid values include "9223372036854775808" and "1.".

xs:NameXML 1.O names.

<xs:simpleType name="Name" id="Name">
  <xs:restriction base="xs:token">
    <xs:pattern value="\i\c*"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:token

Primary:

xs:string

Known subtypes:

xs:NCName

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

The lexical and value spaces of xs:Name are the tokens (NMTOKEN) that conform to the definition of a name in XML 1.0.

Restrictions

Following XML 1.0, those names may contain colons (":"), but no special meaning is attached to these characters. Another datatype (xs:QName) should be used for qualified names when they use namespaces prefixes.

Example

Valid values include "Snoopy", "CMS", or "_1950-10-04_10:00".

Invalid values include "0836217462" (a xs:Name cannot start with a number) or "bold,brash" (commas are forbidden).

xs:NCNameUnqualified names.

<xs:simpleType name="NCName" id="NCName">
  <xs:restriction base="xs:Name">
    <xs:pattern value="[\i-[:]][\c-[:]]*"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:Name

Primary:

xs:string

Known subtypes:

xs:ID, xs:IDREF, xs:ENTITY

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

The lexical and value spaces of xs:NCName are the names (Name) that conform to the definition of a NCName in the Recommendation "Namespaces in XML 1.0"--i.e., all the XML 1.0 names that do not contain colons (":").

Restrictions

This datatype allows characters such as "-" and may need additional constraints to match the notion of name in your favorite programming language or database system.

Example

Valid values include "Snoopy", "CMS", "_1950-10-04_10-00", or "bold_brash".

Invalid values include "_1950-10-04:10-00" or "bold:brash" (colons are forbidden).

xs:negativeIntegerStrictly negative integers of arbitrary length.

<xs:simpleType name="negativeInteger" id="negativeInteger">
  <xs:restriction base="xs:nonPositiveInteger">
    <xs:maxInclusive value="-1"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:nonPositiveInteger

Primary:

xs:decimal

Known subtypes:

none

Facets:

xs:enumeration, xs:fractionDigits, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:totalDigits, xs:whiteSpace

Description

The value space of xs:negativeInteger includes the set of all the strictly negative integers (excluding zero), with no restriction of range. Its lexical space allows any number of insignificant leading zeros.

Restrictions

The decimal point (even when followed only by insignificant zeros) is forbidden.

Example

Valid values for xs:negativeInteger include "-123456789012345678901234567890", "-1", or "-0000000000000000000005".

Invalid values include "0" or "-1.".

xs:NMTOKENXML 1.0 name token (NMTOKEN).

<xs:simpleType name="NMTOKEN" id="NMTOKEN">
  <xs:restriction base="xs:token">
    <xs:pattern value="\c+"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:token

Primary:

xs:string

Known subtypes:

xs:NMTOKENS

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

The lexical and value spaces of xs:NMTOKEN are the set of XML 1.0 "name tokens," i.e., tokens composed of characters, digits, ".", ":", "-", and the characters defined by Unicode, such as "combining" or "extender".

Restrictions

This type is usually called a "token."

Example

Valid values include "Snoopy", "CMS", "1950-10-04", or "0836217462".

Invalid values include "brought classical music to the Peanuts strip" (spaces are forbidden) or "bold,brash" (commas are forbidden).

xs:NMTOKENSList of XML 1.0 name token (NMTOKEN).

<xs:simpleType name="NMTOKENS" id="NMTOKENS">
  <xs:restriction>
    <xs:simpleType>
      <xs:list>
        <xs:simpleType>
          <xs:restriction base="xs:NMTOKEN"/>
        </xs:simpleType>
      </xs:list>
    </xs:simpleType>
    <xs:minLength value="1"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:NMTOKEN

Primary:

none

Known subtypes:

none

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:whiteSpace

Description

xs:NMTOKENS is derived by list from xs:NMTOKEN and represents whitespace-separated lists of XML 1.0 name tokens.

Restrictions

None.

Example

Valid values include "Snoopy", "CMS", "1950-10-04", "0836217462 0836217463", or "brought classical music to the Peanuts strip" (note that, in this case, the sentence is considered as a list of words).

Invalid values include "brought classical music to the "Peanuts" strip" (quotes are forbidden) or "bold,brash" (commas are forbidden).

xs:nonNegativeIntegerIntegers of arbitrary length positive or equal to zero.

<xs:simpleType name="nonNegativeInteger" id="nonNegativeInteger">
  <xs:restriction base="xs:integer">
    <xs:minInclusive value="0"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:integer

Primary:

xs:decimal

Known subtypes:

xs:unsignedLong, xs:positiveInteger

Facets:

xs:enumeration, xs:fractionDigits, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:totalDigits, xs:whiteSpace

Description

The value space of xs:nonNegativeInteger includes the set of all the integers greater than or equal to zero, with no restriction of range. Its lexical space allows any number of insignificant leading zeros.

Restrictions

The decimal point (even when followed only by insignificant zeros) is forbidden.

Example

Valid values include "+123456789012345678901234567890", "0", "0000000000000000000005", or "2147483647".

Invalid values include "1." or "-1.".

xs:nonPositiveIntegerIntegers of arbitrary length negative or equal to zero.

<xs:simpleType name="nonPositiveInteger" id="nonPositiveInteger">
  <xs:restriction base="xs:integer">
    <xs:maxInclusive value="0"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:integer

Primary:

xs:decimal

Known subtypes:

xs:negativeInteger

Facets:

xs:enumeration, xs:fractionDigits, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:totalDigits, xs:whiteSpace

Description

The value space of xs:nonPositiveInteger includes the set of all the integers less than or equal to zero, with no restriction of range. Its lexical space allows any number of insignificant leading zeros.

Restrictions

The decimal point (even when followed only by insignificant zeros) is forbidden.

Example

Valid values include "-123456789012345678901234567890", "0", "-0000000000000000000005", or "-2147483647".

Invalid values include "-1." or "1.".

xs:normalizedStringWhitespace-replaced strings.

<xs:simpleType name="normalizedString" id="normalizedString">
  <xs:restriction base="xs:string">
    <xs:whiteSpace value="replace"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:string

Primary:

xs:string

Known subtypes:

xs:token

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

The lexical space of xs:normalizedString is unconstrained (any valid XML character may be used), and its value space is the set of strings after whitespace replacement (i.e., after any occurrence of #x9 (tab), #xA (linefeed), and #xD (carriage return) have been replaced by an occurrence of #x20 (space) without any whitespace collapsing).

Restrictions

This is the only datatype that performs whitespace replacement without collapsing. When whitespaces are not significant, xs:token is preferred.

This datatype corresponds to neither the XPath function normalize-space( ) (which performs whitespace trimming and collapsing) nor to the DOM "normalize" method (which is a merge of adjacent text objects).

Example

The value of the element:

<title lang="en">
  Being a Dog Is 
  a Full-Time Job
</title>"

is the string: " Being a Dog Is a Full-Time Job ", where all the whitespaces have been replaced by spaces if the title element is a type xs:normalizedString.

xs:NOTATIONEmulation of the XML 1.0 feature.

<xs:simpleType name="NOTATION" id="NOTATION">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:NOTATION

Known subtypes:

none

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

The value and lexical spaces of xs:NOTATION are references to notations declared though the xs:notation element. The use of this element and datatype is, therefore, a namespace-aware emulation of the NOTATION feature of XML 1.0.

Restrictions

Notations are very seldom used in real-world applications.

One cannot use xs:notation directly, but must derive it as shown in the Example.

Example

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
  <xs:notation name="jpeg" public="image/jpeg"
    system="file:///usr/bin/xv"/> 
  <xs:notation name="gif" public="image/gif"
    system="file:///usr/bin/xv"/> 
  <xs:notation name="png" public="image/png"
    system="file:///usr/bin/xv"/> 
  <xs:notation name="svg" public="image/svg"
    system="file:///usr/bin/xsmiles"/> 
  <xs:notation name="pdf" public="application/pdf"
    system="file:///usr/bin/acroread"/>
  <xs:simpleType name="graphicalFormat">
    <xs:restriction base="xs:NOTATION">
      <xs:enumeration value="jpeg"/>
      <xs:enumeration value="gif"/>
      <xs:enumeration value="png"/>
      <xs:enumeration value="svg"/>
      <xs:enumeration value="pdf"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="picture">
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base="xs:base64Binary">
          <xs:attribute name="type" type="graphicalFormat"/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>
</xs:schema>
xs:positiveIntegerStrictly positive integers of arbitrary length.

<xs:simpleType name="positiveInteger" id="positiveInteger">
  <xs:restriction base="xs:nonNegativeInteger">
    <xs:minInclusive value="1"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:nonNegativeInteger

Primary:

xs:decimal

Known subtypes:

none

Facets:

xs:enumeration, xs:fractionDigits, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:totalDigits, xs:whiteSpace

Description

The value space of xs:positiveInteger includes the set of the strictly positive integers (excluding zero), with no restriction of range. Its lexical space allows any number of insignificant leading zeros.

Restrictions

The decimal point (even when followed only by insignificant zeros) is forbidden.

Example

Valid values include "123456789012345678901234567890", "1", or "0000000000000000000005".

Invalid values include "0" or "1.".

xs:QNameNamespaces in XML qualified names.

<xs:simpleType name="QName" id="QName">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:QName

Known subtypes:

none

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

The lexical space of xs:QName is the qualified names per Namespace in XML, i.e., a local name (which is a xs:NCName) with an optional prefix (itself a xs:NCName), separated by a colon (":"), where the prefix is declared a namespace prefix in the scope of the element carrying the value. Its value space comprises the pairs (namespace URI, local name) in which the namespace URI is the URI associated to the prefix in the namespace declaration.

This dissociation between lexical and value spaces makes a lot of difference when using facets such as xs:pattern (which acts on the lexical space only and thus constrains the namespace prefix) and xs:enumeration (which acts on the value space and thus constrains the namespace URI).

Restrictions

It is impossible to apply a pattern on the namespace URI.

The usage of QNames in elements and attributes is controversial since it creates a dependency between the content of the document and its markup. However, the official position of the W3C doesn't discourage this practice.

Example

W3C XML Schema itself has already given us some examples of QNames. When we wrote "<xs:attribute name="lang" type="xs:language"/>", the type attribute was a xs:QName and its value was the tuple {"http://www.w3.org/2001/XMLSchema", "language"} because the URI "http://www.w3.org/2001/XMLSchema" had been assigned to the prefix "xs:". If there had been no namespace declaration for this prefix, the type attribute would have been considered invalid.

xs:short32 bit signed integers.

<xs:simpleType name="short" id="short">
  <xs:restriction base="xs:int">
    <xs:minInclusive value="-32768"/>
    <xs:maxInclusive value="32767"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:int

Primary:

xs:decimal

Known subtypes:

xs:byte

Facets:

xs:enumeration, xs:fractionDigits, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:totalDigits, xs:whiteSpace

Description

The value space of xs:short is the set of common short integers (16 bits), i.e., the integers between -32768 and 32767; its lexical space allows any number of insignificant leading zeros.

Restrictions

The decimal point (even when followed only by insignificant zeros) is forbidden.

Example

Valid values include "-32768", "0", "-0000000000000000000005", or "32767".

Invalid values include "32768" and "1.".

xs:stringAny string.

<xs:simpleType name="string" id="string">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="preserve"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:string

Known subtypes:

xs:normalizedString

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

The lexical and value spaces of xs:string are the set of all possible strings composed of any character allowed in a XML 1.0 document without any treatment done on whitespaces.

Restrictions

This is the only datatype that leaves all the whitespaces. When whitespaces are not significant, xs:token is preferred.

Example

The value of the following element:

<title lang="en">
  Being a Dog Is 
  a Full-Time Job
</title>

is the full string "Being a Dog Is a Full-Time Job", with all its tabulations and CR/LF if the title element is a xs:string type .

xs:timePoint in time recurring each day.

<xs:simpleType name="time" id="time">
  <xs:restriction base="xs:anySimpleType">
    <xs:whiteSpace value="collapse" fixed="true"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:anySimpleType

Primary:

xs:time

Known subtypes:

none

Facets:

xs:enumeration, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:whiteSpace

Description

The lexical space of xs:time is identical to the time part of xs:dateTime ("hh:mm:ss[Z|(+|-)hh:mm]"); and its value space is the set of points in time recurring daily.

Restrictions

The period (one day) is fixed and no calendars other than the Gregorian are supported.

Example

Valid values include "21:32:52", "21:32:52+02:00", "19:32:52Z", "19:32:52+00:00", or "21:32:52.12679".

Invalid values include "21:32" (all the parts must be specified), "25:25:10" (the hour part is out of range), "-10:00:00" (the hour part is out of range), or "1:20:10" (all the digits must be supplied).

xs:tokenWhitespace-replaced and collapsed strings.

<xs:simpleType name="token" id="token">
  <xs:restriction base="xs:normalizedString">
    <xs:whiteSpace value="collapse"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:normalizedString

Primary:

xs:string

Known subtypes:

xs:language, xs:NMTOKEN, xs:Name

Facets:

xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Description

The lexical and value spaces of xs:token are the sets of all the strings after whitespace replacement--i.e., after any occurrence of #x9 (tab), #xA (linefeed), and #xD (carriage return) is replaced by an occurrence of #x20 (space) and collapsing (i.e., the contiguous occurrences of spaces are replaced by a single space, and leading and trailing spaces are removed).

More simply said, xs:token is the most appropriate datatype to use for strings that do not care about whitespaces.

Restrictions

The name xs:token is misleading since whitespaces are allowed within xs:token. xs:NMTOKEN is the type corresponding to what is usually called "tokens."

Example

The element:

<title lang="en">
  Being a Dog Is 
  a Full-Time Job
</title>

is a valid xs:token and its value is the string "Being a Dog Is a Full-Time Job", where all the whitespaces have been replaced by spaces, leading and trailing spaces have been removed and contiguous sequences of spaces have been replaced by single spaces.

xs:unsignedByteUnsigned value of 8 bits.

<xs:simpleType name="unsignedByte" id="unsignedBtype">
  <xs:restriction base="xs:unsignedShort">
    <xs:maxInclusive value="255"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:unsignedShort

Primary:

xs:decimal

Known subtypes:

none

Facets:

xs:enumeration, xs:fractionDigits, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:totalDigits, xs:whiteSpace

Description

The value space of xs:unsignedByte is the integers between 0 and 255, i.e., the unsigned values that can fit in a word of 8 bits. Its lexical space allows an optional "+" sign and leading zeros before the significant digits.

Restrictions

The lexical space does not allow values expressed in other numeration bases (such as hexadecimal, octal, or binary).

The decimal point (even when followed only by insignificant zeros) is forbidden.

Example

Valid values include "255", "0", "+0000000000000000000005", or "1".

Invalid values include "-1" and "1.".

xs:unsignedIntUnsigned integer of 32 bits.

<xs:simpleType name="unsignedInt" id="unsignedInt">
  <xs:restriction base="xs:unsignedLong">
    <xs:maxInclusive value="4294967295"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:unsignedLong

Primary:

xs:decimal

Known subtypes:

xs:unsignedShort

Facets:

xs:enumeration, xs:fractionDigits, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:totalDigits, xs:whiteSpace

Description

The value space of xs:unsignedInt is the integers between 0 and 4294967295, i.e., the unsigned values that can fit in a word of 32 bits. Its lexical space allows an optional "+" sign and leading zeros before the significant digits.

Restrictions

The decimal point (even when followed only by insignificant zeros) is forbidden.

Example

Valid values include "4294967295", "0", "+0000000000000000000005", or "1".

Invalid values include "-1" and "1.".

xs:unsignedLongUnsigned integer of 64 bits.

<xs:simpleType name="unsignedLong" id="unsignedLong">
  <xs:restriction base="xs:nonNegativeInteger">
    <xs:maxInclusive value="18446744073709551615"/>
  </xs:restriction>
</xs:simpleType>

Derived from:

xs:nonNegativeInteger

Primary:

xs:decimal

Known subtypes:

xs:unsignedInt

Facets:

xs:enumeration, xs:fractionDigits, xs:maxExclusive, xs:maxInclusive, xs:minExclusive, xs:minInclusive, xs:pattern, xs:totalDigits, xs:whiteSpace

Description

The value space of xs:unsignedLong is the integers between 0 and 18446744073709551615, i.e., the unsigned values that can fit in a word of 64 bits. Its lexical space allows an optional "+" sign and leading zeros before the significant digits.

Restrictions

The decimal point (even when followed only by insignificant zeros) is forbidden.

Example

Valid values include "18446744073709551615", "0", "+0000000000000000000005", or "1".

Invalid values include "-1" and "1.".



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.