XDM and Atomic Types

The XDM Data Model and Atomic Types

Every XPath value is a sequence of zero or more items, as the XQuery and XPath Data Model (XDM) defines it. An item is a node (one of seven kinds), an atomic value of an XML Schema type, or a function, which in 3.1 includes maps and arrays. A single item and a sequence of one item are the same thing.

The XDM type hierarchy, abridged: every value is a sequence of these items
The XDM type hierarchy, abridged: every value is a sequence of these items

Of the fifty or so built-in atomic types, the everyday ones are strings, xs:decimal (exact, for money) and its subtype xs:integer, xs:double, xs:boolean, dates, times, durations and xs:anyURI. Saxon 726,956 's adaptive output shows each value's type:

Literals, constructed values and untyped document data
xp '42' '4.2e0' 'xs:date("2026-10-01")' 'map { "id": "b1" }' \
   'data(//book[1]/pages) instance of xs:untypedAtomic' '//book[1]/pages + 1'
Output
42                                     => 42
4.2e0                                  => 4.2e0
xs:date("2026-10-01")                  => xs:date("2026-10-01")
map { "id": "b1" }                     => map{"id":"b1"}
data(//book[1]/pages) instance of xs:untypedAtomic => true()
//book[1]/pages + 1                    => 3.13e2

The last two lines matter most for data work: without a schema, an element's value is xs:untypedAtomic, text that becomes whatever type an operation demands, and arithmetic makes it an xs:double, so 312 pages plus one prints as 3.13e2. A schema-aware processor that validated the catalog against an XSD (Schema-Aware XSLT) would type pages as xs:integer; Saxon-HE is not schema-aware, so cast explicitly (Casting and Constructors).


Data Types

XPath's data model (XDM) defines a type hierarchy for every value a path expression can produce. The tree below lists all available data types, with subtypes indented under their parent type.

A normalizedString is a string that does not contain line feeds, carriage returns, or tabs.

A token is a string that does not contain line feeds, carriage returns, tabs, leading or trailing spaces, or multiple consecutive spaces.

XPath 3.1 defines several further string subtypes beyond those listed above.

A value can be cast to a type using the type's constructor function, e.g. xs:numeric(true()) returns 1.

Date and Time Examples

CategoryExamples
date2015-03-04
2015-03-04Z (UTC time)
2015-03-04+08:00
time13:30:10
13:30:10.6
12:00:00Z (UTC time)
12:00:00+08:00
datetime2015-03-04T12:00:00
2015-03-04T12:00:00Z (UTC time)
2015-03-04T12:00:00+08:00
durationP5Y3M9DT15H30M30S
P3M (3 months)
PT3M (3 minutes)
-P3D
ch03-datatype-cast.xmlXML
xs:numeric(true())
Output
1