Up: Plexippus XPath API reference

Package xpath

Plexippus XPath is an XPath 1.0 implementation for Common Lisp.

About This Package

Using XPath
Compiling XPath dynamically
Type coercion
The dynamic environment
The run-time context
Node sets
Miscellaneous

Using XPath

Almost all uses of XPath involve the evaluate function, which can parse, compile, and invoke XPath expressions.

Evaluates an XPath expression ...

This macro is used to specify sexpr-based XPath expression for evaluate

Compiling XPath dynamically

compile-xpath allows the compilation of XPath into a closure ahead of time, so that evaluate only needs to invoke that closure rather than having to re-compile it first.

Although evaluate itself already performs caching of compiled closures, explicit precompilation can aid optimizations if one call site uses multiple XPath expressions.

Explicit compilation using compile-xpath is also required when using custom environment classes, since evaluate compiles expressions using the dynamic environment only.

parse-xpath can be used to translate the standard string representation of XPath into a Plexippus-specific sexp representation. Both compile-xpath and evaluate accept sexps instead of strings.

Parses a string-based XPath expression into s-expression-based one.

Compiles an XPath expression ...

Type coercion

These correspond to the XPath functions boolean(), string(), and number(). In addition, node-set-value is provided, which turns nodes into node sets.

Returns the value of XPath boolean() function. ...

Returns the value of XPath number() function. ...

Returns the value of XPath number() function. ...

Returns the value of XPath node-set() function. ...

The dynamic environment

The default enviroment used by evaluate is the dynamic environment, backed by information bound in dynamic variables. The following macros are used to bind these variables. They have dynamic scope. (The dynamic environment is currently not capable of dynamic declarations for variables, but can be used with extension functions that are declared globally.)

(The XPATH-SYS defined an environment protocol for user-defined environment classes.)

Provides namespace bindings for XPath compilation ...

Provides bindings for XPath variables ...

The run-time context

Instead of passing a node to evaluate, user code can construct a full context object.

The context object specifies values to be returned by position(), current(), and last().

Represents XPath context

Makes a context object.

Returns the context node of the XPath context.

Returns the node for which the whole XPath expression is evaluated.

Returns the current position of the XPath context.

Returns the size of context ...

Node sets

Node sets are the XPath data type used to represent the results of evaluations that select multiple nodes. As sets, they never contain duplicates.

In addition to the high-level functions defined here, the XPATH-SYS package defined several low-level node set functions. Please also refer to the description there for details on node set order.

Returns the first node in the node-set or nil if it's empty.

Returns all nodes of the node-set as a list.

Calls func for each node in node-set ...

Calls func for each node in node-set and conses up a list of its return values ...

Executes body with var bound to successive nodes in node-set ...

Creates a node set iterator for node-set ...

Returns true if iterator points to the end of its node set

Advances iterator if it's not at the end of its node set, does nothing otherwise.

Returns current node of iterator or nil if it's at the end of its node set.

Returns true if object is a node-set

Returns true if node-set is empty

Makes a node-set from the list of nodes.

Sorts the node-set according to document order.

Miscellaneous

Other useful functions, variables, and classes:

Binds plx prefix to Plexippus XPath extensions namespace. ...

*navigator*
The class of all xpath errors.

Exported Symbol Index

*navigator*, variable  (undocumented)
all-nodes, function
boolean-value, function
compile-xpath, function
context, class
context-node, function
context-position, function
context-size, function
context-starting-node, function
do-node-set, macro
evaluate, function
evaluate-compiled, function
first-node, function
list->node-set, function
make-context, function
make-node-set-iterator, function
map-node-set, function
map-node-set->list, function
node-set, class
node-set-empty-p, function
node-set-iterator-current, function
node-set-iterator-end-p, function
node-set-iterator-next, function
node-set-p, function
node-set-value, function
number-value, function
parse-xpath, function
sort-node-set, function
string-value, function
with-namespaces, macro
with-plx-extensions, macro
with-variables, macro
xpath, macro
xpath-error, function
xpath-error, class