Predicates

These are just a small sampling of the selections that predicates make possible.

XPointer predicate expressions do have one small distinction from the expressions used in XSLT. The result of an XPointer predicate expression is ultimately converted to a boolean after all calculations are finished. Non-boolean results are converted as follows:

The predicate expression is evaluated for each node in the context node list. Each node for which the expression ultimately evaluates to false is removed from the list. Thus only those nodes that satisfy the predicate remain. I will not repeat here the discussion of the operators and functions available to use expressions. However, I will show you a few examples of predicates using the expression syntax as it's likely to be used in XPointers.

Probably the function most frequently used in XPointer predicates is position(). This returns the index of the node in the context node list. This allows you to find the first, second, third, or other indexed node. You can compare positions using the various relational operators like <, >, =, !=, >=, and <=.

xpointer(/child::FAMILYTREExpointer(/child::*[position()=1])
xpointer(/child::FAMILYTREExpointer(/child::*[position()=2])
xpointer(/child::FAMILYTREExpointer(/child::*[position()=3])
xpointer(/child::FAMILYTREExpointer(/child::*[position()=4])
xpointer(/child::FAMILYTREExpointer(/child::*[position()=5])
xpointer(/child::FAMILYTREExpointer(/child::*[position()=6])
xpointer(/child::FAMILYTREExpointer(/child::*[position()=7])
xpointer(/child::FAMILYTREExpointer(/child::*[position()=8])
xpointer(/child::FAMILYTREExpointer(/child::*[position()=9])
xpointer(/child::FAMILYTREExpointer(/child::*[position()=10])
xpointer(/child::FAMILYTREExpointer(/child::*[position()=11])
xpointer(/child::FAMILYTREExpointer(/child::*[position()=12])
xpointer(/child::FAMILYTREExpointer(/child::*[position()=13])
xpointer(/child::FAMILYTREExpointer(/child::*[position()=14])

Previous | Next | Top | Cafe con Leche

Copyright 2000 Elliotte Rusty Harold
elharo@metalab.unc.edu
Last Modified February 1, 2000