Package net.sf.saxon.expr
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.
-
ClassDescriptionThis class performs the first phase of processing in "constructing simple content": it takes an input sequence, eliminates empty text nodes, and combines adjacent text nodes into one.Elaborator for an adjacent text node merging expression - inserted into a pipeline for node constructionElaborator for an AndExpression (P and Q)Arithmetic Expression: an expression using one of the operators plus, minus, multiply, div, idiv, mod.Elaborator for an ArithmeticExpression (for example P + Q)An Iterator that produces numeric values in a monotonic sequence, ascending or descending.Assignation is an abstract superclass for the kinds of expression that declare range variables: for, some, and every.An AtomicSequenceConverter is an expression that performs a cast (or other supplied conversion) on each member of a supplied sequenceElaborator for an AtomicSequenceConverter (including an UntypedAtomicConverter, which is the same except that it uses a different converter internally)Mapping function wrapped around a converterMapping function that converts every item in a sequence to a stringAn Atomizer is an expression corresponding essentially to the fn:data() function: it maps a sequence by replacing nodes with their typed valuesElaborator for an AtomizerAn AttributeGetter is an expression that returns the value of a specific attribute of the context item, provided that it is an untyped element node.Elaborator for an AttributeGetter expression (which gets a named attribute of the context item and returns its value as an untyped atomic value)This iterator returns a sequence of atomic values, the result of atomizing the sequence of nodes returned by an underlying SequenceIterator.An AxisExpression is always obtained by simplifying a PathExpression.Elaborator for an AxisExpressionAn Iterator that produces numeric values in a monotonic ascending or descending sequence, where the integers may exceed the range of a LongBinary Expression: a numeric or boolean expression consisting of the two operands and an operatorBinding is a interface used to represent the run-time properties and methods associated with a variable: specifically, a method to get the value of the variable.BindingReference is a interface used to mark references to a variable declaration.Boolean expression: two truth values combined using AND or OR.This class evaluates arithmetic expressions; it acts as a helper class to the ArithmeticExpression class.Arithmetic: anyAtomicType div AnyAtomicTypeArithmetic: anyAtomicType idiv AnyAtomicTypeArithmetic: anyAtomicType - AnyAtomicTypeArithmetic: anyAtomicType mod AnyAtomicTypeArithmetic: anyAtomicType + AnyAtomicTypeArithmetic: anyAtomicType * AnyAtomicTypeArithmetic: decimal div decimal (including types that promote to decimal, that is, integer)Arithmetic: decimal idiv decimal (including types that promote to decimal, that is, integer)Arithmetic: decimal - decimal (including types that promote to decimal, that is, integer)Arithmetic: decimal mod decimal (including types that promote to decimal, that is, integer)Arithmetic: decimal + decimal (including types that promote to decimal, that is, integer)Arithmetic: decimal * decimal (including types that promote to decimal, that is, integer)Arithmetic: double div double (including types that promote to double)Arithmetic: double - double (including types that promote to double)Arithmetic: double mod double (including types that promote to double)Marker interface for operations on doublesArithmetic: double + double (including types that promote to double)Arithmetic: double * double (including types that promote to double)Arithmetic: float div float (including types that promote to float)Arithmetic: float idiv float (including types that promote to float)Arithmetic: float - float (including types that promote to float)Arithmetic: float mod float (including types that promote to float)Arithmetic: float + float (including types that promote to float)Arithmetic: float * float (including types that promote to float)Arithmetic: integer div integerArithmetic: integer idiv integerArithmetic: integer - integerArithmetic: integer mod integerArithmetic: integer + integerArithmetic: integer * integerA generic interface for calling expressions by supplying the values of their subexpressionsAn implementation of
Callable
that allows the logic to be supplied as a lambda expression.A CardinalityChecker implements the cardinality checking of "treat as": that is, it returns the supplied sequence, checking that its cardinality is correctElaborator for atreat as
expression, which is usually system-generated by the type checking phase of the compilerCardinalityCheckingIterator returns the items in an underlying sequence unchanged, but checks that the number of items conforms to the required cardinality.Castable Expression: implements "Expr castable as atomic-type?".Cast Expression: implements "cast as data-type ( expression )".Elaborator forcast as
expression, or the equivalent constructor function callCasting Expression: abstract superclass for "cast as X" and "castable as X", which share a good deal of logicThis class implements a comparison of a computed value to a literal constant using one of the operators eq, ne, lt, gt, le, ge.This class implements a comparison of a numeric value to an integer constant using one of the operators eq, ne, lt, gt, le, ge.Elaborator for a "compare to integer constant" expressionThis class implements a comparison of a computed value to a string constant using one of the operators eq, ne, lt, gt, le, ge.Elaborator for a "compare to string constant" expressionInterface implemented by expressions that perform a comparisonRepresents a component as defined in the XSLT 3.0 specification: for example a function, a named template, an attribute set, a global variable.A ComponentBinding is a reference from one component to another; for example a variable reference or function call.Represents an expression or instruction such as call-template, or a user function call, or a global variable reference, that needs to be bound to a target component, and can potentially be re-bound when the containing component is copied into another package.This expression is used as a proxy for the consuming operand of an expression such as an arithmetic expression for which there is no explicit streaming support.This class represents the expression "(dot)", which always returns the context item.Elaborator for the context item expression, "dot".ContextMappingFunction is an interface that must be satisfied by an object passed to a ContextMappingIterator.ContextMappingIterator merges a sequence of sequences into a single flat sequence.Represents a construct that is responsible for originating a new context; used in analysing the stack of context objects for diagnosticsInterface implemented by expressions that switch the context, for example A/B or A[B]The expression is generated when compiling the current() function in XSLT.DefaultedArgumentExpression
is a placeholder used in a function call for an argument that is evaluated using the default value expression from the function definition, in cases where that expression has not yet been compiled (typically because the function call precedes the function declaration).Iterator that produces numeric values in a monotonic sequence, ascending or descending.An enumeration representing a nodeset that is teh difference of two other NodeSets.This class implements the function fn:apply(), which is a standard function in XQuery 3.1.An EagerLetExpression is the same as a LetExpression except that the variable is evaluated using eager evaluation rather than lazy evaluation.This class is an implementation of XPathContext used when evaluating constant sub-expressions at compile time.This class performs part of the processing in "constructing simple content": it takes an input sequence and eliminates empty text nodes into one.Elaborator for an empty text node remove expression - inserted into a pipeline for node constructionError expression: this expression is generated when the supplied expression cannot be parsed, and the containing element enables forwards-compatible processing.A SequenceIterator that throws an exception as soon as its next() method is called.An export agent performs the job of exporting an expression to a SEF file.Interface supported by an XPath expression.Abstraction representing any class that can act as the container for an expression: either an Operand of a parent expression, or a top-level construct such as a function or template or XQuery expressionA FilterExpression contains a base expression and a filter predicate, which may be an integer expression (positional filter), or a boolean expression (qualifier)Elaborator for a filter expressionAn iterator for a filter expression in which the predicate is capable of evaluating as a number (in which case it needs to be compared with the context position, rather than being converted to a boolean)An iterator for a filter expression where it is known that the filter value will not be numeric, and can therefore be evaluated directly as a booleanA FilterIterator filters an input sequence using a filter expression.A FirstItemExpression returns the first item in the sequence returned by a given base expressionAn elaborator for a "first-item" expression, typically written asX[1]
or ashead(X)
.A ForExpression maps an expression over a sequence.An elaborator for a "for" expression, typically written as {for $x in SEQ return R}.The MappingAction represents the action to be taken for each item in the source sequence.Abstract superclass for calls to system-defined and user-defined functionsGeneralComparison: a boolean expression that compares two expressions for equals, not-equals, greater-than or less-than.Elaborator for a general comparison expression such as (A = B).The class GeneralComparison20 specializes GeneralComparison for the case where the comparison is done with 2.0 semantics (i.e.A reference to a global variableElaborator for a global variable reference, for example$globalVar
.This class is an expression that does a run-time check of the result of a "/" expression to ensure that (a) the results consists entirely of atomic values and function items, or entirely of nodes, and (b) if the results are nodes, then they are deduplicated and sorted into document order.Elaborator for a homogeneity checker, which checks that the items in a sequence are either all nodes, or all non-nodes.IdentityComparison: a boolean expression that compares two nodes for equals, not-equals, greater-than or less-than based on identity and document orderingElaborator for an identity comparison (operatorsis
,<<
, and>>
)InstanceOf Expression: implements "Expr instance of data-type"Elaborator for aninstance of
expressionAn IntegerRangeTest is an expression of the form E = N to M where N and M are both expressions of type integer.An enumeration representing a nodeset that is an intersection of two other NodeSets.A position() eq last() expression, generated by the optimizer.Elaborator for an "isLast" expression, equivalent toposition() = last()
orposition() != last()
A ItemChecker implements the item type checking of "treat as": that is, it returns the supplied sequence, checking that all its items are of the correct type.Elaborator for atreat as
expression, which is usually system-generated by the type checking phase of the compilerItemCheckingIterator applies a supplied function to each item in a sequence.ItemMapper is an implementation ofItemMappingFunction
that wraps a predicate function typically supplied as a lambda expression: unlike a standard Predicate, however, the test is allowed to throw anXPathException
.ItemMapper is an implementation ofItemMappingFunction
that wraps a function typically supplied as a lambda expression.ItemMappingFunction is an interface that must be satisfied by an object passed to a ItemMappingIterator.ItemMappingIterator applies a mapping function to each item in a sequence.A mapping function for use in conjunction with anItemMappingIterator
that checks that all the items in a sequence are instances of a given item typeThis class together with its embedded subclasses handles conversion from Java values to XPath values.A generic interface for calling expressions by supplying the values of their subexpressionsA LastItemExpression returns the last item in the sequence returned by a given base expression.Elaborator for a "last item expression" (typicallySEQ[last()]
)A LastPositionFinder is an interface implemented by any SequenceIterator that is able to return the position of the last item in the sequence.A LetExpression represents the XQuery construct let $x := expr return expr.Elaborator for a let expression (eitherlet $x := SELECT return ACTION
in XPath, or the equivalent sequence constructor using localxsl:variable
declarations in XSLT).A function item representing a castability test for a list typeA function item representing a constructor function for a list typeA Literal is an expression whose value is constant: it is a class that implements theExpression
interface as a wrapper around aGroundedValue
.Elaborator for a literal.Binding for local variables and parameters: anything that is allocated a slot on the XPathContext stack frame.Variable reference: a reference to a local variable.Elaborator for a local variable reference, for example$var
.Represents a construct that has a meaningful location for use in diagnosticsA lookup expression is an expression of the form A?*, where A must be a map or an arrayA lookup expression is an expression of the form A?B.MappingFunction is an interface that must be satisfied by an object passed to a MappingIterator.MappingIterator merges a sequence of sequences into a single flat sequence.This interface is implemented by expressions that returns a boolean value, and returns an expression whose result is the negated boolean valueNegate Expression: implements the unary minus operator.Elaborator for a negate expression (that is, unary minus)This expression performs the formatting part of the logic of the xsl:number instruction It takes as input a sequence of integers, which may either be supplied directly as the value attribute of xsl:number, or may be computed by counting nodes.Information about a sub-expression and its relationship to the parent expressionDefines the role of a child expression relative to its parent expression.The usage of an operand defines how the containing expression makes use of the value of the operand, as defined in the XSLT 3.0 specification.Elaborator for an "or" expression (A or B
)Information about a unit of compilation: in XSLT, a package; in XQuery, a module.A PendingUpdateList is created by updating expressions in XQuery Update.This class together with its embedded subclasses handles conversion from XPath values to Java valuesConverter for use when the source object is an atomic value, but nothing more is known statically.General-purpose converter when nothing more specific is available.Converter for use when the target class is an arrayConverter for use when the target class is a collection class.Converter for use when the target class isOne
, which constrains the value to be a singletonConverter for use when the target class isOneOrMore
, which constrains the value to be a non-empty sequenceConverter for use when the target class isZeroOrMore
, which allows any sequence but is a generic (parameterized) class so there is compile-time information about the type of itemsConverter for use when the target class isZeroOrOne
, which constrains the value to be a singleton or an empty sequenceA pseudo-expression is an object that can appear as a node on the expression tree, but which cannot actually be evaluated in its own right.A QuantifiedExpression tests whether some/all items in a sequence satisfy some condition.Elaborator for a quantified expression (some|every X in Y satisfies Z
)A RangeExpression is an expression that represents an integer sequence as a pair of end-points (for example "x to y").An expression whose value is always a set of nodes containing a single node, the document root.Elaborator for a root expression (/
)SequenceMapper is an implementation ofMappingFunction
that wraps a function typically supplied as a lambda expression.An abstract implementation of Expression designed to make it easy to implement new expressions, in particular, expressions to support extension instructions.A SimpleStepExpression is a special case of a SlashExpression in which the start expression selects a single item (or nothing), and the step expression is a simple AxisExpression.Elaborator for a simple step expression, that is X/axis::Y where X evaluates to a singletonA SingleItemFilter is an expression that selects zero or one items from a supplied sequenceA SingletonAtomizer combines the functions of an Atomizer and a CardinalityChecker: it is used to atomize a sequence of nodes, checking that the result of the atomization contains zero or one atomic values.This expression is equivalent to (A intersect B) in the case where A has cardinality zero-or-one.Elaborator for a Venn expression: that isA union B
,A intersect B
, orA except B
A slash expression is any expression using the binary slash operator "/".Elaborator for a slash expression.This class represents a stack frame holding details of the variables used in a function or in an XSLT template.A StaticContext contains the information needed while an expression or pattern is being parsed.A call to a function that is known statically.This class contains constants identifying dependencies that an XPath expression might have on its context.Subclass of Literal used specifically for string literals, as this is a common caseA SubscriptExpression represents a FilterExpression of the form EXPR[n] where n is known to be singleton numeric and to be independent of the focus; it does not need to be constantAn elaborator for a "subscript" expression, typically written asX[$n]
where$n
is an integer or a numeric expression.A SubsequenceIterator selects a subsequence of a sequenceSupplied parameter reference: this is an internal expression used to refer to the value of the n'th parameter supplied on a template call or a call to an inline function.A comparer that compares atomic values for equality, with the properties: - non-comparable types compare false - NaN compares equal to NaN Used for comparisons in XQuery Switch expressionsClass to handle comparisons for XQuery switch expressions.A call to a system-defined function (specifically, a function implemented as an instance ofSystemFunction
)Subclass representing a system function call that has been optimized; this overrides the optimize() method to do nothing, thus ensuring that optimization converges.Elaborator for a system function call, used in cases where the specific function call has no custom supportA TailCallLoop wraps the body of a function that contains tail-recursive function calls.A TailExpression represents a FilterExpression of the formEXPR[position() > n]
Here n is usually 2, but we allow other valuesElaborator for a tail expressionTailIterator iterates over a base sequence starting at an element other than the first.Treat Expression: implements "treat as data-type ( expression )".This class implements a try/catch expression.Unary Expression: an expression taking a single operand expressionFunction to test castability to a union typeFunction to perform a cast to a union typeAn enumeration representing a nodeset that is a union of two other NodeSets.A multi-way union delivering the sorted results obtained from a number of sorted input iteratorsAn UntypedSequenceConverter is an expression that performs a cast on each member of a supplied sequence that is an untypedAtomic value, while leaving other items unchangedA Converter that converts untyped atomic values to the required type, while leaving other values unchangedElaborator for an UntypedSequenceConverterThis class represents a call to a user-defined function in the stylesheet or query.A reference to a function; typically a forwards reference to a user-defined function in XQuery that has not yet been compiled.ValueComparison: a boolean expression that compares two atomic values for equals, not-equals, greater-than or less-than.Elaborator for a value comparison (such asA eq B
), including the case where a general comparison is reduced to a value comparison by the optimiserValueTailIterator
iterates over a base sequence starting at an element other than the first.Variable reference: a reference to a variable.An expression representing a nodeset that is a union, difference, or intersection of two other NodeSetsElaborator for a Venn expression: that isA union B
,A intersect B
, orA except B
This class represents a context in which an XPath expression is evaluated.This class represents a "major context" in which an XPath expression is evaluated: a "major context" object allows all aspects of the dynamic context to change, whereas a "minor context" only allows changes to the focus and the destination for push output.The ThreadManager is used to manage asynchronous execution of xsl:result-document instructions in Saxon-EE.This class represents a minor change in the dynamic context in which an XPath expression is evaluated: a "major context" object allows all aspects of the dynamic context to change, whereas a "minor context" only allows changes to the focus and the destination for push output.Container for cached value of the last() function.