com.saxonica.stream

## Class ExpressionInverter

- java.lang.Object
- - 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

    Constructors
    Constructor and Description
    `ExpressionInverter(Configuration config)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `consumesGroup(Expression exp)`
    `static boolean` | `consumesStream(Expression exp)` Ask whether an expression is consuming.
    `static int` | `getStreamability(Expression exp, int syntacticContext, boolean allowExtensions, List<String> reasons)` Implement the default streamability rules for an expression.
    `Inversion` | `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 Inversion 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

    - #### getStreamability

          public static int getStreamability(Expression exp,
                             int syntacticContext,
                             boolean allowExtensions,
                             List<String> reasons)

      Implement the default streamability rules for an expression. This code is used only for expressions that have no specific streamability rules of their own Get the "sweep" of this expression as defined in the W3C streamability specifications. This provides an assessment of stylesheet code against the W3C criteria for guaranteed streamability, and is implemented to allow these criteria to be tested. It is not the case that all expression that emerge as streamable from this analysis are currently capable of being streamed by Saxon
      Parameters:
        `exp` - the expression being analyzed
        `syntacticContext` - one of the values `Expression.NAVIGATION_CONTEXT`, `Expression.NODE_VALUE_CONTEXT`, `Expression.INHERITED_CONTEXT`, `Expression.INSPECTION_CONTEXT`
        `allowExtensions` - if false, the definition of "guaranteed streamability" in the W3C specification is used. If true, Saxon extensions are permitted, which make some
        `reasons` - the caller may supply a list, in which case the implementation may add to this list a message explaining why the construct is not streamable, suitable for inclusion in an error message.
      Returns:
        one of the values `Expression.W3C_MOTIONLESS`, `Expression.W3C_CONSUMING`, `Expression.W3C_GROUP_CONSUMING`, `Expression.W3C_FREE_RANGING`

    - #### 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

    - #### consumesGroup

          public static boolean consumesGroup(Expression exp)

    - #### 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)
      Parameters:
        `exp` - the expression being examined
      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
      Parameters:
        `exp` - the expression being examined
      Returns:
        true if it doesreturn an ancestor

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