MENU
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