Datatypes in XPath 1.0
In XPath 1.0, an expression returns one of four datatypes:
node-setRepresents a set of nodes. The set can be empty or it can contain any number of nodes.
booleanRepresents the value
trueorfalse. Be aware that thetrueorfalsestrings have no special meaning or value in XPath; see Converting to boolean values” in Chapter 5 for a more detailed discussion of these.numberRepresents a floating-point number. All numbers in XPath and XSLT are implemented as floating-point numbers; the
integer(orint) datatype does not exist in XPath and XSLT. Specifically, all numbers are implemented as IEEE 754 floating-point numbers, which is the same standard used by the Javafloatanddoubleprimitive types. In addition to ordinary numbers, there are five special values for numbers: positive and negative infinity, positive and negative zero, andNaN, the special symbol for anything that is not a number.stringRepresents zero or more characters, as defined in the XML specification.
These datatypes are usually simple, and with the exception of node-sets, converting between types is usually straightforward. We won’t discuss these datatypes in any more detail here; instead, we’ll discuss datatypes and conversions as we need them to do specific tasks.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access