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
The principal classes are:
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.
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.
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.
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:
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
(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
Interface Summary Interface Description BindingBinding 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. BindingReferenceBindingReference is a interface used to mark references to a variable declaration. CallableA generic interface for calling expressions by supplying the values of their subexpressions ComparisonExpressionInterface implemented by expressions that perform a comparison ComponentInvocationRepresents 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. ContextMappingFunctionContextMappingFunction is an interface that must be satisfied by an object passed to a ContextMappingIterator. ContextOriginatorRepresents a construct that is responsible for originating a new context; used in analysing the stack of context objects for diagnostics ContextSwitchingExpressionInterface implemented by expressions that switch the context, for example A/B or A[B] ExportAgentAn export agent performs the job of exporting an expression to a SEF file. ExpressionOwnerAbstraction 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 expression ItemMappingFunctionItemMappingFunction is an interface that must be satisfied by an object passed to a ItemMappingIterator. LastPositionFinderA LastPositionFinder is an interface implemented by any SequenceIterator that is able to return the position of the last item in the sequence. LocalBindingBinding for local variables and parameters: anything that is allocated a slot on the XPathContext stack frame. LocatableRepresents a construct that has a meaningful location for use in diagnostics MappingFunctionMappingFunction is an interface that must be satisfied by an object passed to a MappingIterator. NegatableThis interface is implemented by expressions that returns a boolean value, and returns an expression whose result is the negated boolean value PendingUpdateListA PendingUpdateList is created by updating expressions in XQuery Update. StaticContextA StaticContext contains the information needed while an expression or pattern is being parsed. TailCallLoop.TailCallInfo UserFunctionResolvableA reference to a function; typically a forwards reference to a user-defined function in XQuery that has not yet been compiled. XPathContextThis class represents a context in which an XPath expression is evaluated.
Class Summary Class Description AdjacentTextNodeMergerThis 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. AnalyzeMappingFunctionMapping function that maps the sequence of matching/non-matching strings to the sequence delivered by applying the matching-substring and non-matching-substring expressions respectively to each such string AndExpression ArithmeticExpressionArithmetic Expression: an expression using one of the operators plus, minus, multiply, div, idiv, mod. AssignationAssignation is an abstract superclass for the kinds of expression that declare range variables: for, some, and every. AtomicSequenceConverterAn AtomicSequenceConverter is an expression that performs a cast (or other supplied conversion) on each member of a supplied sequence AtomicSequenceConverter.AtomicSequenceMappingFunctionMapping function wrapped around a converter AtomicSequenceConverter.ToStringMappingFunctionMapping function that converts every item in a sequence to a string AtomizerAn Atomizer is an expression corresponding essentially to the fn:data() function: it maps a sequence by replacing nodes with their typed values AttributeGetterAn AttributeGetter is an expression that returns the value of a specific attribute of the context item, provided that it is an untyped element node. AxisAtomizingIteratorThis iterator returns a sequence of atomic values, the result of atomizing the sequence of nodes returned by an underlying SequenceIterator. AxisExpressionAn AxisExpression is always obtained by simplifying a PathExpression. BigRangeIteratorAn Iterator that produces numeric values in a monotonic sequence, where the integers may exceed the range of a Long BinaryExpressionBinary Expression: a numeric or boolean expression consisting of the two operands and an operator BooleanExpressionBoolean expression: two truth values combined using AND or OR. CalculatorThis class evaluates arithmetic expressions; it acts as a helper class to the ArithmeticExpression class. Calculator.AnyDivAnyArithmetic: anyAtomicType div AnyAtomicType Calculator.AnyIdivAnyArithmetic: anyAtomicType idiv AnyAtomicType Calculator.AnyMinusAnyArithmetic: anyAtomicType - AnyAtomicType Calculator.AnyModAnyArithmetic: anyAtomicType mod AnyAtomicType Calculator.AnyPlusAnyArithmetic: anyAtomicType + AnyAtomicType Calculator.AnyTimesAnyArithmetic: anyAtomicType * AnyAtomicType Calculator.DecimalDivDecimalArithmetic: decimal div decimal (including types that promote to decimal, that is, integer) Calculator.DecimalIdivDecimalArithmetic: decimal idiv decimal (including types that promote to decimal, that is, integer) Calculator.DecimalMinusDecimalArithmetic: decimal - decimal (including types that promote to decimal, that is, integer) Calculator.DecimalModDecimalArithmetic: decimal mod decimal (including types that promote to decimal, that is, integer) Calculator.DecimalPlusDecimalArithmetic: decimal + decimal (including types that promote to decimal, that is, integer) Calculator.DecimalTimesDecimalArithmetic: decimal * decimal (including types that promote to decimal, that is, integer) Calculator.DoubleDivDoubleArithmetic: double div double (including types that promote to double) Calculator.DoubleMinusDoubleArithmetic: double - double (including types that promote to double) Calculator.DoubleModDoubleArithmetic: double mod double (including types that promote to double) Calculator.DoublePlusDoubleArithmetic: double + double (including types that promote to double) Calculator.DoubleTimesDoubleArithmetic: double * double (including types that promote to double) Calculator.FloatDivFloatArithmetic: float div float (including types that promote to float) Calculator.FloatIdivFloatArithmetic: float idiv float (including types that promote to float) Calculator.FloatMinusFloatArithmetic: float - float (including types that promote to float) Calculator.FloatModFloatArithmetic: float mod float (including types that promote to float) Calculator.FloatPlusFloatArithmetic: float + float (including types that promote to float) Calculator.FloatTimesFloatArithmetic: float * float (including types that promote to float) Calculator.IntegerDivIntegerArithmetic: integer div integer Calculator.IntegerIdivIntegerArithmetic: integer idiv integer Calculator.IntegerMinusIntegerArithmetic: integer - integer Calculator.IntegerModIntegerArithmetic: integer mod integer Calculator.IntegerPlusIntegerArithmetic: integer + integer Calculator.IntegerTimesIntegerArithmetic: integer * integer CardinalityCheckerA CardinalityChecker implements the cardinality checking of "treat as": that is, it returns the supplied sequence, checking that its cardinality is correct CardinalityCheckingIteratorCardinalityCheckingIterator returns the items in an underlying sequence unchanged, but checks that the number of items conforms to the required cardinality. CastableExpressionCastable Expression: implements "Expr castable as atomic-type?". CastExpressionCast Expression: implements "cast as data-type ( expression )". CastingExpressionCasting Expression: abstract superclass for "cast as X" and "castable as X", which share a good deal of logic CompareToConstantThis class implements a comparison of a computed value to a literal constant using one of the operators eq, ne, lt, gt, le, ge. CompareToIntegerConstantThis class implements a comparison of a numeric value to an integer constant using one of the operators eq, ne, lt, gt, le, ge. CompareToStringConstantThis class implements a comparison of a computed value to a string constant using one of the operators eq, ne, lt, gt, le, ge. ComponentRepresents a component as defined in the XSLT 3.0 specification: for example a function, a named template, an attribute set, a global variable. Component.M ComponentBindingA ComponentBinding is a reference from one component to another; for example a variable reference or function call. ConsumingOperandThis 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. ContextItemExpressionThis class represents the expression "(dot)", which always returns the context item. ContextMappingIteratorContextMappingIterator merges a sequence of sequences into a single flat sequence. CurrentItemExpressionThe expression is generated when compiling the current() function in XSLT. DifferenceEnumerationAn enumeration representing a nodeset that is teh difference of two other NodeSets. EagerLetExpressionAn EagerLetExpression is the same as a LetExpression except that the variable is evaluated using eager evaluation rather than lazy evaluation. EarlyEvaluationContextThis class is an implementation of XPathContext used when evaluating constant sub-expressions at compile time. EmptyTextNodeRemoverThis class performs part of the processing in "constructing simple content": it takes an input sequence and eliminates empty text nodes into one. EquivalenceComparerA comparer that compares atomic values for equality, with the properties: - non-comparable types compare false - NaN compares equal to NaN EquivalenceComparisonClass to handle equivalence comparisons of singletons. ErrorExpressionError expression: this expression is generated when the supplied expression cannot be parsed, and the containing element enables forwards-compatible processing. ErrorIteratorA SequenceIterator that throws an exception as soon as its next() method is called. ExpressionInterface supported by an XPath expression. FilterExpressionA FilterExpression contains a base expression and a filter predicate, which may be an integer expression (positional filter), or a boolean expression (qualifier) FilterIteratorA FilterIterator filters an input sequence using a filter expression. FilterIterator.NonNumericSubclass to handle the common special case where it is statically known that the filter cannot return a numeric value FirstItemExpressionA FirstItemExpression returns the first item in the sequence returned by a given base expression ForExpressionA ForExpression maps an expression over a sequence. ForExpression.MappingActionThe MappingAction represents the action to be taken for each item in the source sequence. FunctionCallAbstract superclass for calls to system-defined and user-defined functions GeneralComparisonGeneralComparison: a boolean expression that compares two expressions for equals, not-equals, greater-than or less-than. GeneralComparison20The class GeneralComparison20 specializes GeneralComparison for the case where the comparison is done with 2.0 semantics (i.e. GlobalVariableReferenceA reference to a global variable HomogeneityCheckerThis 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. IdentityComparisonIdentityComparison: a boolean expression that compares two nodes for equals, not-equals, greater-than or less-than based on identity and document ordering InstanceOfExpressionInstanceOf Expression: implements "Expr instance of data-type" IntegerRangeTestAn IntegerRangeTest is an expression of the form E = N to M where N and M are both expressions of type integer. IntersectionEnumerationAn enumeration representing a nodeset that is an intersection of two other NodeSets. IsLastExpressionA position() eq last() expression, generated by the optimizer. ItemCheckerA 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 ItemMappingIteratorItemMappingIterator applies a mapping function to each item in a sequence. ItemTypeCheckingFunctionA mapping function for use in conjunction with an
ItemMappingIteratorthat checks that all the items in a sequence are instances of a given item type
JPConverterThis class together with its embedded subclasses handles conversion from Java values to XPath values. JPConverter.ExternalObjectWrapper JPConverter.FromBigDecimal JPConverter.FromBigInteger JPConverter.FromBoolean JPConverter.FromBooleanArray JPConverter.FromByte JPConverter.FromByteArray JPConverter.FromCharacter JPConverter.FromCharArray JPConverter.FromCollection JPConverter.FromDate JPConverter.FromDouble JPConverter.FromDoubleArray JPConverter.FromFloat JPConverter.FromFloatArray JPConverter.FromInstant JPConverter.FromInt JPConverter.FromIntArray JPConverter.FromLocalDate JPConverter.FromLocalDateTime JPConverter.FromLong JPConverter.FromLongArray JPConverter.FromObject JPConverter.FromObjectArray JPConverter.FromOffsetDateTime JPConverter.FromQName JPConverter.FromSequence JPConverter.FromSequenceIterator JPConverter.FromShort JPConverter.FromShortArray JPConverter.FromSource JPConverter.FromString JPConverter.FromURI JPConverter.FromXdmValue JPConverter.FromZonedDateTime JPConverter.VoidConverter LastItemExpressionA LastItemExpression returns the last item in the sequence returned by a given base expression. LetExpressionA LetExpression represents the XQuery construct let $x := expr return expr. ListCastableFunctionA function item representing a castability test for a list type ListConstructorFunctionA function item representing a constructor function for a list type Literal LocalVariableReferenceVariable reference: a reference to a local variable. LookupAllExpressionA lookup expression is an expression of the form A?*, where A must be a map or an array LookupExpressionA lookup expression is an expression of the form A?B. MappingIteratorMappingIterator merges a sequence of sequences into a single flat sequence. MultiIterator<T>An iterator that combines the results of a sequence of iterators NegateExpressionNegate Expression: implements the unary minus operator. NumberSequenceFormatterThis 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. OperandInformation about a sub-expression and its relationship to the parent expression OperandRoleDefines the role of a child expression relative to its parent expression. OrExpression PackageDataInformation about a unit of compilation: in XSLT, a package; in XQuery, a module. PJConverterThis class together with its embedded subclasses handles conversion from XPath values to Java values PJConverter.AnyURIValueToURI PJConverter.AnyURIValueToURL PJConverter.AtomicConverter for use when the source object is an atomic value, but nothing more is known statically. PJConverter.BooleanValueToBoolean PJConverter.CalendarValueToCalendar PJConverter.CalendarValueToDate PJConverter.CalendarValueToInstant PJConverter.CalendarValueToLocalDateTime PJConverter.CalendarValueToOffsetDateTime PJConverter.CalendarValueToZonedDateTime PJConverter.DateValueToLocalDate PJConverter.GeneralGeneral-purpose converter when nothing more specific is available. PJConverter.Identity PJConverter.IntegerValueToBigInteger PJConverter.IntegerValueToByte PJConverter.IntegerValueToChar PJConverter.IntegerValueToInt PJConverter.IntegerValueToLong PJConverter.IntegerValueToShort PJConverter.NumericValueToBigDecimal PJConverter.NumericValueToDouble PJConverter.NumericValueToFloat PJConverter.QualifiedNameValueToQName PJConverter.StringValueToChar PJConverter.StringValueToString PJConverter.ToArrayConverter for use when the target class is an array PJConverter.ToCollectionConverter for use when the target class is a collection class. PJConverter.ToNull PJConverter.ToOneConverter for use when the target class is
One, which constrains the value to be a singleton
PJConverter.ToOneOrMoreConverter for use when the target class is
OneOrMore, which constrains the value to be a non-empty sequence
PJConverter.ToSequenceExtent PJConverter.ToSequenceIterator PJConverter.ToZeroOrMoreConverter for use when the target class is
ZeroOrMore, which allows any sequence but is a generic (parameterized) class so there is compile-time information about the type of items
PJConverter.ToZeroOrOneConverter for use when the target class is
ZeroOrOne, which constrains the value to be a singleton or an empty sequence
PJConverter.UnwrapExternalObject PseudoExpressionA 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. QuantifiedExpressionA QuantifiedExpression tests whether some/all items in a sequence satisfy some condition. RangeExpressionA RangeExpression is an expression that represents an integer sequence as a pair of end-points (for example "x to y"). RangeIteratorAn Iterator that produces numeric values in a monotonic sequence, ascending or descending. ReverseRangeIteratorIterator that produces numeric values in a monotonic sequence, ascending or descending. RootExpressionAn expression whose value is always a set of nodes containing a single node, the document root. SimpleExpressionAn abstract implementation of Expression designed to make it easy to implement new expressions, in particular, expressions to support extension instructions. SimpleStepExpressionA 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. SingleItemFilterA SingleItemFilter is an expression that selects zero or one items from a supplied sequence SingletonAtomizerA 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. SingletonIntersectExpressionThis expression is equivalent to (A intersect B) in the case where A has cardinality zero-or-one. SlashExpressionA slash expression is any expression using the binary slash operator "/". StackFrameThis class represents a stack frame holding details of the variables used in a function or in an XSLT template. StaticFunctionCallA call to a function that is known statically. StaticPropertyThis class contains constants identifying dependencies that an XPath expression might have on its context. StringLiteralSubclass of Literal used specifically for string literals, as this is a common case SubscriptExpressionA 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 constant SubsequenceIteratorA SubsequenceIterator selects a subsequence of a sequence SuppliedParameterReferenceSupplied 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. SystemFunctionCallA call to a system-defined function (specifically, a function implemented as an instance of
SystemFunctionCall.OptimizedSubclass representing a system function call that has been optimized; this overrides the optimize() method to do nothing, thus ensuring that optimization converges. TailCallLoopA TailCallLoop wraps the body of a function that contains tail-recursive function calls. TailCallLoop.TailCallComponent TailCallLoop.TailCallFunction TailExpressionA TailExpression represents a FilterExpression of the form
EXPR[position() > n]Here n is usually 2, but we allow other values
TailIteratorTailIterator iterates over a base sequence starting at an element other than the first. TreatExpressionTreat Expression: implements "treat as data-type ( expression )". TryCatchThis class implements a try/catch expression. TryCatch.CatchClause UnaryExpressionUnary Expression: an expression taking a single operand expression UnionCastableFunctionFunction to test castability to a union type UnionConstructorFunctionFunction to perform a cast to a union type UnionEnumerationAn enumeration representing a nodeset that is a union of two other NodeSets. UnionIteratorA multi-way union delivering the sorted results obtained from a number of sorted input iterators UntypedSequenceConverterAn UntypedSequenceConverter is an expression that performs a cast on each member of a supplied sequence that is an untypedAtomic value, while leaving other items unchanged UntypedSequenceConverter.UntypedConverterA Converter that converts untyped atomic values to the required type, while leaving other values unchanged UserFunctionCallThis class represents a call to a user-defined function in the stylesheet or query. ValueComparisonValueComparison: a boolean expression that compares two atomic values for equals, not-equals, greater-than or less-than. ValueTailIteratorValueTailIterator iterates over a base sequence starting at an element other than the first. VariableReferenceVariable reference: a reference to a variable. VennExpressionAn expression representing a nodeset that is a union, difference, or intersection of two other NodeSets XPathContextMajorThis 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. XPathContextMajor.ThreadManagerThe ThreadManager is used to manage asynchronous execution of xsl:result-document instructions in Saxon-EE. XPathContextMinorThis 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. XPathContextMinor.LastValueContainer for cached value of the last() function.
Enum Summary Enum Description EvaluationModeAn evaluation mode represents a way in which expressions can be evaluated GeneralComparison.ComparisonCardinality OperandUsageThe 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.