22.2. Data Types
expression evaluates to one of four types:
A binary value that is either true
or false. In XPath, Booleans are most commonly produced by using the
comparison operators =, !=,
<=, and >=. Multiple
conditions can be combined using the and and
or operators, which have their usual meaning in
logic (e.g., 3>2 or 2>1 is true.) XPath does
not offer Boolean literals. However, the true( )
and false( ) functions fill that need.
All numbers in XPath, which are IEEE
754-compliant, 64-bit floating point numbers. This is the same as the
double type in Java. Numbers range from
4.94065645841246544e-324d to 1.79769313486231570e+308d, and are
either positive or negative. Numbers also include the special values
Inf (positive infinity), -Inf
(negative infinity), and NaN (not a number), which
is used for the results of illegal operations, such as dividing by
zero. XPath provides all the customary operators for working with
Subtraction; however, this operator should always be surrounded by
whitespace to avoid accidental misinterpretation as part of an XML
Taking the remainder
Sequence of zero or more Unicode
characters. String literals are enclosed in either single or double
quotes, as convenient. Unlike Java, XPath does not allow strings to
be concatenated with the plus sign. However, the concat(
) function serves this purpose.
Collection of zero or more nodes from an
XML document. Location paths produce most node-sets. Generally, a
single node-set can contain every kind of node: root, element,
attribute, namespace, comment, processing instruction, and text.
However, most node-sets contain a single type of node.
Some standards that use XPath also define additional data types. For
instance, XSLT defines a result tree fragment type that represents
the result of processing an XSLT instruction or instantiating a
template. XPointer defines a location set type that extends node-sets
to include points and ranges.
Copyright © 2002 O'Reilly & Associates. All rights reserved.