com.saxonica.stream
Class ExpressionInverter

java.lang.Object
  extended by com.saxonica.stream.ExpressionInverter

public class ExpressionInverter
extends Object

This class performs inversion of an expression so that it can be evaluated in push mode as events are received from the XML parser. If the expression is invertible, the result of the inversion has three components: a set of actions to be performed before the events are received from the parser; a WatchMaker which is used at run-time to construct a Watch (which listens to the parser events), and a set of actions to be performed after parsing the subtree.


Constructor Summary
ExpressionInverter(Configuration config)
           
 
Method Summary
static boolean consumesStream(Expression exp)
          Ask whether an expression is consuming.
 InvertedExpression invertExpression(Expression exp)
          Compute the Jackson inversion of an expression.
static boolean isUpwardsExpression(Expression exp)
          Test whether an expression returns an ancestor of the context node
static boolean returnsStreamedNode(Expression exp)
          Test whether an expression returns a node in the streamed document (that is, the same document as the context node)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionInverter

public ExpressionInverter(Configuration config)
Method Detail

invertExpression

public InvertedExpression invertExpression(Expression exp)
                                    throws XPathException
Compute the Jackson inversion of an expression. The effect is (a) to determine whether the expression is streamable (throwing an exception if not), and (b) to construct the "Streaming route", that is, the path through the expression tree containing expressions that perform downward navigation within the streamed document

Parameters:
exp - the expression to be inverted
Returns:
the inverted expression
Throws:
XPathException - if the expression is not streamable

consumesStream

public static boolean consumesStream(Expression exp)
Ask whether an expression is consuming. A consuming expression is one that depends on the focus and depends on data that can only be obtained by advancing the parser within the input stream

Specifically, this allows access to certain functions of the context item (such as name() and base-uri()), access to attributes of the context item, and access to attributes of ancestors of the context item.

Parameters:
exp - the expression to be tested
Returns:
true if the expression is a navigating expression, that is, if it makes a downward selection

returnsStreamedNode

public static boolean returnsStreamedNode(Expression exp)
Test whether an expression returns a node in the streamed document (that is, the same document as the context node)

Returns:
true if the expression is capable of returning a sequence of nodes that includes a node in the same document as the context node. (It may also be capable of returning nodes in other documents)

isUpwardsExpression

public static boolean isUpwardsExpression(Expression exp)
Test whether an expression returns an ancestor of the context node

Returns:
true if it does


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