Class Streamability

java.lang.Object
com.saxonica.ee.stream.Streamability

public class Streamability extends Object
Supporting class for assessing the streamability of expressions. Among other things, it contains an implementation of the General Streamability Rules.
  • Constructor Details

    • Streamability

      public Streamability()
  • Method Details

    • getConsumingOperand

      public static Operand getConsumingOperand(Expression exp)
      Get the consuming (or potentially consuming) operand of an expression, assuming there is exactly one
      Parameters:
      exp - the expression
      Returns:
      if there are one or more consuming subexpressions, then the first of these; otherwise, null. Also returns null if the posture and sweep have not yet been assessed.
    • rewriteQuantifiedExpressionAsFilterExpression

      public static Expression rewriteQuantifiedExpressionAsFilterExpression(QuantifiedExpression quant) throws XPathException
      Throws:
      XPathException
    • rewriteForExpressionAsMappingExpression

      public static Expression rewriteForExpressionAsMappingExpression(ForExpression forEx)
    • generalStreamabilityRules

      public static PostureAndSweep generalStreamabilityRules(Expression target, Iterable<Operand> operands, ContextItemStaticInfoEE contextInfo, List<String> reasons)
      Implement the general streamability rules; the rules used to determine the posture and sweep of any expression except when more specific rules are defined for that class of expression
      Parameters:
      target - the expression whose streamability is being analyzed (used only for diagnostics)
      operands - the operands of the expression being evaluated
      contextInfo - information about the static context item type and posture
      reasons - (optionally null) an array to which explanations of non-streamability should be appended
      Returns:
      the posture and sweep of the expression
    • isChildlessNodeKind

      public static boolean isChildlessNodeKind(ItemType type)
      Ask whether an ItemType only allows nodes that cannot have children
      Parameters:
      type - the item type
      Returns:
      true if the item type only allows nodes that cannot have children
    • toStreamingPattern

      public static Pattern toStreamingPattern(Expression expr, Configuration config)
      Convert an expression to a streaming pattern (a pattern used internally to match nodes during push processing of an event stream)
      Parameters:
      expr - the expression to be converted
      config - the Saxon configuration
      Returns:
      the equivalent pattern if conversion succeeds; otherwise null
    • getStreamability

      public static PostureAndSweep getStreamability(Expression exp, ContextItemStaticInfoEE contextInfo, List<String> reasons)
      Get the posture and 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:
      contextInfo - Information about the context item type and posture
      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
      Returns:
      the posture and sweep of the expression
    • getPosture

      public static Posture getPosture(Expression exp)
    • getSweep

      public static Sweep getSweep(Expression exp)
    • getPostureAndSweepIfKnown

      public static PostureAndSweep getPostureAndSweepIfKnown(Expression exp)
      Get the posture and sweep of the expression if these have already been computed
      Returns:
      the posture and sweep if known, or null if the streamability has not yet been assessed.
    • setPostureAndSweep

      public static void setPostureAndSweep(Expression exp, PostureAndSweep ps)
    • computeAccumulatorAfterSweep

      public static Sweep computeAccumulatorAfterSweep(SystemFunctionCall call, ContextItemStaticInfoEE contextInfo, List<String> reasons)
      Compute the sweep of a call to accumulator-after (which depends on what else is found in the same sequence constructor
      Parameters:
      call - the call on accumulator-after
      Returns:
      the computed sweep, which is consuming if all previous instructions are motionless, or motionless if a previous instruction is consuming.
    • wider

      public static Sweep wider(Sweep a, Sweep b)
      Return the wider of two sweeps. The order of increasing width is MOTIONLESS, CONSUMING, FREE_RANGING.
      Parameters:
      a - the first sweep
      b - the second sweep
      Returns:
      the wider of the two
    • isIncrementalPosture

      public static boolean isIncrementalPosture(Posture posture)
      Test whether a supplied posture is either striding or crawling
      Parameters:
      posture - the posture to be tested
      Returns:
      true if this posture is either striding or crawling
    • combinedPosture

      public static Posture combinedPosture(Set<Posture> postures)
      Get the combined posture of a set of postures, as defined in the XSLT 3.0 specification
      Parameters:
      postures - the set of postures
      Returns:
      the combined posture