Package net.sf.saxon.expr

This package provides classes associated with XPath expression handling.

See: Description

Package net.sf.saxon.expr Description

This package provides classes associated with XPath expression handling. Generally, these classes are not intended to be used directly by user-written applications; the API for XPath evaluation is now provided by classes in the package net.sf.saxon.xpath

The principal classes are:

Expression:
This represents an XPath Expression. There is a static method Expression.make() which is used to construct an Expression from a String (it is a factory method rather than a constructor, because it typically returns some subclass of Expression according to the syntax supplied). Subclasses of Expression represent different kinds of expression such as StringExpression and BooleanExpression. What they all have in common is an evaluate() method, which evaluates the expression in a given context to yield a Value, and an iterate() method, which treats the result of the expression as a sequence, and iterates over the items in the sequence.

ExpressionParser:
This class does the work of parsing both Expressions and Patterns. Applications should not call it directly. It uses the class Tokenizer for lexical analysis.

StaticContext:
This interface defines the information available at the time an expression is being parsed. This includes the names of variables, the bindings of namespace prefixes, the functions that are available, the names of collating sequences, and so on. When an XPath expression appears in a stylesheet, the class net.sf.saxon.style.ExpressionContext provides the StaticContext. For a free-standing XPath expression, the class net.sf.saxon.xpath.StandaloneContext is available, though a user-written class that implements StaticContext can also be used.

XPathContext:
This class defines the context information available at run-time, for example the context node, position, and size. (It actually does this by wrapping a SequenceIterator that represents the current sequence.) When expressions are used during an XSLT transformation, the XPathContext also provides access to the Controller, which contains all the context information about XSLT processing (for example the current template, the current group, and so on).

Most of the classes in this package represent individual syntactic constructs found in XPath or XQuery expressions: for example ValueComparison, UserFunctionCall, and RootExpression. The objects that instantiate these classes form the nodes on the Abstract Syntax Tree constructed by the compiler and modified by the optimizer; at run-time their methods are used to drive a pipelined evaluation of the expression.

The distinction between the compiled form of XSLT instructions and the compiled form of XPath expressions has become blurred. Generally, the compiled form of instructions is in the package net.sf.saxon.instruct (this includes expressions in XQuery that are equivalent to XSLT instructions, for example element constructors). However, some constructs such as conditional expressions now exist in both languages and may generate the same run-time constructs.


Michael H. Kay
Saxonica Limited
9 February 2005

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.