DB2 10.5 for Linux, UNIX, and Windows

Type system

XQuery is a strongly-typed language in which the operands of various expressions, operators, and functions must conform to expected types. The type system for DB2® XQuery includes the built-in types of XML Schema and the predefined types of XQuery.

The built-in types of XML Schema are in the namespace http://www.w3.org/2001/XMLSchema, which has the predeclared namespace prefix xs. Some examples of built-in schema types include xs:integer, xs:string, and xs:date.

The predefined types of XQuery are in the namespace http://www.w3.org/2005/xpath-datatypes, which has the predeclared namespace prefix xdt. Some examples of predefined types of XQuery include xdt:untypedAtomic, xdt:yearMonthDuration, and xdt:dayTimeDuration.

Each data type has a lexical form, which is a string that can be cast into the given type or that can be used to represent a value of the given type after serialization.