Data Types

The following tree shows all available data types in XPath, with the subtypes indented to the right.

item()
   function(*)
   node()
      attribute()
      comment()
      document()
      element()
      namespace()
      processing-instruction()
      text()
   xs:anyAtomicType
      xs:untypedAtomic
      xs:boolean
      xs:base64Binary (eg. '  AAAA  FFFF ', groups of 4-digit HEX)
      xs:hexBinary (eg. '  AF12  ', 4-digit HEX)
      xs:anyURI
      xs:QName (eg. '  ab12  ', no symbol, no intermediate space)
      xs:NOTATION
      xs:float
      xs:double
      xs:decimal
         xs:integer
            xs:nonPositiveInteger
               xs:negativeInteger
            xs:long
               xs:int
                  xs:short
                     xs:byte
            xs:nonNegativeInteger
               xs:positiveInteger
               xs:unsignedLong
                  xs:unsignedLong
                     xs:unsignedInt
                        xs:unsignedShort
                           xs:unsignedByte
      xs:string
         xs:normalizedString
            xs:token (eg. '   a   b  c  1 2 $%^&*&*&3   ')
               xs:language (eg. 'abc', no space, no symbol, no digit)
               xs:NMTOKEN (eg. 'abc123', no space, no symbol)
               xs:Name (eg. ' abc',one leading space only, no symbol)
                  xs:NCName
                     xs:ID
                     xs:IDREF
                     xs:ENTITY
      xs:gYearMonth (eg. '2014-05')
      xs:gYear (eg. '2014')
      xs:gMonthDay (eg. '--05-31')
      xs:gDay (eg. '---30')
      xs:gMonth (eg. '--06')
      xs:date (eg. '2015-08-31')
      xs:time (eg. '18:30:30')
      xs:dateTime (eg. '2015-03-04T12:00:00')
         xs:dateTimeStamp (eg. '2015-03-04T12:00:00Z')
      xs:duration (eg. 'P1Y2M3D')
         xs:yearMonthDuration (eg. 'P1Y2M')
         xs:dayTimeDuration (eg. 'P10DT6H30M30S')

xs:anyType
   user-defined complex types
   xs:untyped
   xs:anySimpleType
      xs:IDREFS
      xs:NMTOKENS
      xs:ENTITIES
      xs:anyAtomicType
(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 spaces.)

(Some other string types are also described in 6.3.1.)

Date and Time 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