[2.0] XPath 2.0 Datatypes

XML Schema defines 19 primitive datatypes, and five others (xs:anyAtomicType, xs:untyped, xs:untypedAtomic, xs:dayTimeDuration, and xs:yearMonthDuration) were added to the XML Schema namespace by the XQuery 1.0 and XPath 2.0 Data Model spec. We’ll review those briefly here.

XPath 1.0 used the node-set datatype as its basic data structure; XPath 2.0 uses sequences. Like a node-set, a sequence can contain the node types we covered earlier in this appendix, but it can also contain atomic values of the types listed here.

Here are the 24 datatypes:

xs:anyAtomicType

The base type for all primitive atomic types, such as xs:integer or xs:string. This datatype was added by XQuery 1.0 and XPath 2.0.

xs:anyURI

A Uniform Resource Identifier. The value can be absolute or relative, and it can also have a fragment reference identifier. The value should follow the rules for URI syntax as defined in RFC 2396 and amended in RFC 2732.

xs:base64Binary

Arbitrary binary data represented using the Base64 alphabet defined in RFC 2045. Legal characters are the basic alpha characters and digits [a-zA-Z0-9], along with the plus sign (+), the forward slash (/), and the equals sign (=). An xs:base64Binary value can also contain any number of whitespace characters.

xs:boolean

The value true or false. In XSLT and XPath, the strings "true" and "false" have no special meaning. To generate boolean values, use the functions true() and false() instead.

xs:date

A date with four components: year, month, ...

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.