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.

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:
xp '42' '4.2e0' 'xs:date("2026-10-01")' 'map { "id": "b1" }' \
'data(//book[1]/pages) instance of xs:untypedAtomic' '//book[1]/pages + 1'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.13e2The 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.- item() — the root type for any single value in a sequence.
- function(*) — any function item
- node()
- attribute()
- comment()
- document()
- element()
- namespace()
- processing-instruction()
- text()
- xs:anyAtomicType
- xs:error (a union type)
- xs:untypedAtomic
- xs:boolean
- xs:base64Binary (e.g. AAAAFFFF, groups of 4-digit HEX)
- xs:hexBinary (e.g. AF12, 4-digit HEX)
- xs:anyURI
- xs:QName (e.g. ab12, no symbol, no intermediate space)
- xs:NOTATION
- xs:numeric (a union type)
- xs:float
- xs:double
- xs:decimal
- xs:integer
- xs:nonPositiveInteger
- xs:negativeInteger
- xs:long
- xs:int
- xs:short
- xs:byte
- xs:short
- xs:int
- xs:nonNegativeInteger
- xs:positiveInteger
- xs:unsignedLong
- xs:unsignedInt
- xs:unsignedShort
- xs:unsignedByte
- xs:unsignedShort
- xs:unsignedInt
- xs:nonPositiveInteger
- xs:integer
- xs:string
- xs:normalizedString
- xs:token (e.g. a b c 1 2 $%^&*&*&3)
- xs:language (e.g. abc — no space, no symbol, no digit)
- xs:NMTOKEN (e.g. abc123 — no space, no symbol)
- xs:Name (e.g. abc — one leading space only, no symbol)
- xs:NCName
- xs:ID
- xs:IDREF
- xs:ENTITY
- xs:NCName
- xs:token (e.g. a b c 1 2 $%^&*&*&3)
- xs:normalizedString
- xs:gYearMonth (e.g. 2014-05)
- xs:gYear (e.g. 2014)
- xs:gMonthDay (e.g. --05-31)
- xs:gDay (e.g. ---30)
- xs:gMonth (e.g. --06)
- xs:date (e.g. 2015-08-31)
- xs:time (e.g. 18:30:30)
- xs:dateTime (e.g. 2015-03-04T12:00:00)
- xs:dateTimeStamp (e.g. 2015-03-04T12:00:00Z)
- xs:duration (e.g. P1Y2M3D)
- xs:yearMonthDuration (e.g. P1Y2M)
- xs:dayTimeDuration (e.g. P10DT6H30M30S)
- xs:anyType — the root of the separate XSD type hierarchy.
- user-defined complex types
- xs:untyped
- xs:anySimpleType
- xs:IDREFS
- xs:NMTOKENS
- xs:ENTITIES
- xs:anyAtomicType
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
| Category | Examples |
| date | 2015-03-04 2015-03-04Z (UTC time) 2015-03-04+08:00 |
| time | 13:30:10 13:30:10.6 12:00:00Z (UTC time) 12:00:00+08:00 |
| datetime | 2015-03-04T12:00:00 2015-03-04T12:00:00Z (UTC time) 2015-03-04T12:00:00+08:00 |
| duration | P5Y3M9DT15H30M30S P3M (3 months) PT3M (3 minutes) -P3D |
xs:numeric(true())
1