A query, whether XPath or SQL, specifies a subset of nodes within a workspace, called the result set. The result set constitutes all the nodes in the workspace that meet the constraints stated in the query. The constraints fall into three categories:
Type constraint: This limits the returned nodes to a particular primary node type (and possibly, additionally limits the nodes to those with particular mixin node types).
Property constraint: This limits the returned nodes to those with particular properties having particular values.
Path constraint: This limits the returned nodes to those within certain subtrees in the workspace.
A query result is returned in two parallel forms: an iterator over the result set of nodes and a table where each row corresponds to a node in the result set. The query statement also defines aspects of how these two return objects are structured through two presentation specifiers:
Column specifier: This specifies the set of properties that will form the columns of the returned table.
Ordering specifier: This defines the order of the nodes in the iterator and rows in the table.
The following sections describe in more detail how each of these five elements are expressed, both in XPath and in SQL, and how these affect the content and presentation of the query result.