<html>
<head>
<title>XPath Operators</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="Description">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
<tr>
<td valign="top" class="NAME" colspan="2">XPath Operators</td>
</tr>
<tr>
<td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
</tr>
<tr>
<td valign="top" colspan="2" class="description">

    <p>
<!--<primary>operators (XPath)</primary>-->

All operators defined by XPath are listed here. </p>
</td></tr>
</table>
</div>
<div id="MathematicalOperators">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr valign="top">
<td class="NAME">
Mathematical Operators</td>
<td class="COMPATIBILITY">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
</tr>
<tr><td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr><td colspan="2" class="description">
      <dl>
<dt>
<span class="LITERAL">
+
</span>
(plus)
</dt>
<dd>
<!--<primary>mathematics</primary>
  <secondary>XPath operators for</secondary>-->
Adds one number to another
<P></p>
<dt>
<span class="LITERAL">
-
</span>
(minus)
</dt>
<dd>
Subtracts one number from another
<P></p>
<dt>
<span class="LITERAL">
*
</span>
(multiplication)
</dt>
<dd>
Multiplies one number by another
<P></p>
<dt>
<span class="LITERAL">
div
</span>
</dt>
<dd>
Performs a floating-point division between two numbers
<P></p>
<dt>
<span class="LITERAL">
mod
</span>
</dt>
<dd>
Returns the floating-point remainder of dividing one number by another
<P></p>
</dl>
    </td>
</tr>
</table>
</div>
<div id="BooleanOperators">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr valign="top">
<td class="NAME">
Boolean Operators</td>
<td class="COMPATIBILITY">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
</tr>
<tr><td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr><td colspan="2" class="description">
      <dl>
<dt>
<span class="LITERAL">
=
</span>
</dt>
<dd>
<!--<primary>boolean operators (XPath)</primary>-->
Tests whether two expressions are equal.
<P></p>
<dt>
<span class="LITERAL">
&lt;
</span>
</dt>
<dd>
Tests whether the first expression is less than the second. Within an attribute, this operator must be coded
<span class="LITERAL">
&amp;
lt;
</span>
.
<P></p>
<dt>
<span class="LITERAL">
&lt;
=
</span>
</dt>
<dd>
Tests whether the first expression is less than or equal to the second. Within an attribute, this operator must be coded
<span class="LITERAL">
&amp;
lt;=
</span>
.
<P></p>
<dt>
<span class="LITERAL">
&gt;
</span>
</dt>
<dd>
Tests whether the first expression is greater than the second. Within an attribute, this operator can be coded
<span class="LITERAL">
&amp;
gt;
</span>
.
<P></p>
<dt>
<span class="LITERAL">
&gt;
=
</span>
</dt>
<dd>
Tests whether the first expression is greater than or equal to the second. Within an attribute, this operator can be coded
<span class="LITERAL">
&amp;
gt;=
</span>
.
<P></p>
<dt>
<span class="LITERAL">
!=
</span>
</dt>
<dd>
Tests whether the two expressions are not equal.
<P></p>
<dt>
<span class="LITERAL">
and
</span>
</dt>
<dd>
Tests whether both the first and second expressions are
<span class="LITERAL">
true
</span>
. If the first expression is
<span class="LITERAL">
false
</span>
, the second is not evaluated.
<P></p>
<dt>
<span class="LITERAL">
or
</span>
</dt>
<dd>
Tests whether either the first or second expressions are
<span class="LITERAL">
true
</span>
. If the first expression is
<span class="LITERAL">
true
</span>
, the second is not evaluated.
<P></p>
</dl>
      <sect3 role="" label="B.4.2.1" id="xslt-ID-B.4.2.1">
        <refentrytitle>Comparing values of various datatypes</refentrytitle>
        <p>For the first six boolean operators, comparing values of various datatypes is complicated. We explain the various possibilities here:</p>
        


<dl>
<dt>
If both objects are boolean values
</dt>
<dd>
Then they are equal if they have the same value. For less-than and greater-than comparisons,
<span class="LITERAL">
false
</span>
is considered less than
<span class="LITERAL">
true
</span>
(the function call
<span class="LITERAL">
number(false())
</span>
returns
<span class="LITERAL">
0
</span>
, while
<span class="LITERAL">
number(true())
</span>
returns
<span class="LITERAL">
1
</span>
).
<P></p>
<dt>
If both objects are numbers
</dt>
<dd>
Then the operators work just the way you'd think they would.
<P></p>
<dt>
If both objects are strings
</dt>
<dd>
Then they are equal if their Unicode characters are identical. For less-than and greater-than comparisons, the character codes are compared.
<P></p>
<dt>
If neither object is a node-set and the operator is = or !=
</dt>
<dd>
Then the two objects are converted to the same object type, and the comparison works as described previously. If one of the objects is a boolean, then the objects are converted to boolean values as if by a call to the
<span class="LITERAL">
boolean()
</span>
function. If none of the objects are boolean, the next attempted conversion is to a number. If one of the objects is a number, then the objects are converted to numeric values as if by a call to the
<span class="LITERAL">
number()
</span>
function. Otherwise, all objects are converted to strings as if by a call to the
<span class="LITERAL">
string()
</span>
function.
<P></p>
<dt>
If neither object is a node-set and the operator is
&lt;
,
&gt;
, or
&gt;
=
</dt>
<dd>
Then the objects are converted to numbers and compared.
<P></p>
<dt>
If one or both of the objects is a node-set
</dt>
<dd>
Then things really get complicated. If both objects are node-sets, a comparison is true when the string value of at least one node in the first node-set is equal to the string value of at least one node in the second node-set. If one object is a node-set and the other is a number, string, or boolean, the comparison is true when there is at least one node in the node set whose number, string, or boolean value is equal to that number, string, or boolean value.
<P></p>
</dl>
      </sect3>
    </td>
</tr>
</table>
</div>
<div id="ExpressionOperators">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr valign="top">
<td class="NAME">
Expression Operators</td>
<td class="COMPATIBILITY">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
</tr>
<tr><td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr><td colspan="2" class="description">
      <dl>
<dt>
<span class="LITERAL">
/
</span>
</dt>
<dd>
<!--<primary>expression operators</primary>-->
The stepping operator, which is used to separate steps in a location path. If an XPath expression begins with
<span class="LITERAL">
/
</span>
, it represents the root of the document.
<P></p>
<dt>
<span class="LITERAL">
//
</span>
</dt>
<dd>
The abbreviated syntax for the
<span class="LITERAL">
descendant-or-self
</span>
axis.
<P></p>
<dt>
<span class="LITERAL">
.
</span>
</dt>
<dd>
The abbreviated syntax for the
<span class="LITERAL">
self
</span>
axis.
<P></p>
<dt>
<span class="LITERAL">
..
</span>
</dt>
<dd>
The abbreviated syntax for the
<span class="LITERAL">
parent
</span>
axis.
<P></p>
<dt>
<span class="LITERAL">
@
</span>
</dt>
<dd>
The abbreviated syntax for the
<span class="LITERAL">
attribute
</span>
axis.
<P></p>
<dt>
<span class="LITERAL">
|
</span>
</dt>
<dd>
The union operator. For example, the
<span class="LITERAL">
match
</span>
attribute in the element
<span class="LITERAL">
&lt;
xsl:template match=
"
a|b
"
&gt;
</span>
matches all
<span class="LITERAL">
&lt;
a
&gt;
</span>
and
<span class="LITERAL">
&lt;
b
&gt;
</span>
elements.
<P></p>
<dt>
<span class="LITERAL">
*
</span>
</dt>
<dd>
A wildcard that represents any node of the principal node type.
<span class="LITERAL">
child::*
</span>
selects all element children of the context node,
<span class="LITERAL">
attribute::*
</span>
selects all attributes of the context node, etc. Using the abbreviated syntax,
<span class="LITERAL">
*
</span>
selects all element children of the context node, and
<span class="LITERAL">
@*
</span>
selects all attributes of the context node. Contrast the wildcard operator with the
<span class="LITERAL">
node()
</span>
node test, which matches any node, regardless of type.
<P></p>
<dt>
<span class="LITERAL">
[]
</span>
</dt>
<dd>
The predicate operator, used to contain a predicate expression that filters a group of nodes.
<P></p>
<dt>
<span class="LITERAL">
$
</span>
</dt>
<dd>
The variable operator, used to indicate that a given symbol is a variable name.
<P></p>
</dl>
</td>
</tr>
</table>
</div>
</body>
</html>