Package com.saxonica.ee.stream
Class Streamability
java.lang.Object
com.saxonica.ee.stream.Streamability
Supporting class for assessing the streamability of expressions. Among other things, it contains
an implementation of the General Streamability Rules.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Posture
combinedPosture
(Set<Posture> postures) Get the combined posture of a set of postures, as defined in the XSLT 3.0 specificationstatic 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 constructorstatic 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 expressionstatic Operand
Get the consuming (or potentially consuming) operand of an expression, assuming there is exactly onestatic Posture
getPosture
(Expression exp) static PostureAndSweep
Get the posture and sweep of the expression if these have already been computedstatic PostureAndSweep
getStreamability
(Expression exp, ContextItemStaticInfoEE contextInfo, List<String> reasons) Get the posture and sweep of this expression as defined in the W3C streamability specifications.static Sweep
getSweep
(Expression exp) static boolean
isChildlessNodeKind
(ItemType type) Ask whether an ItemType only allows nodes that cannot have childrenstatic boolean
isIncrementalPosture
(Posture posture) Test whether a supplied posture is either striding or crawlingstatic Expression
static Expression
static void
setPostureAndSweep
(Expression exp, PostureAndSweep ps) 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)static Sweep
Return the wider of two sweeps.
-
Constructor Details
-
Streamability
public Streamability()
-
-
Method Details
-
getConsumingOperand
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
-
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 evaluatedcontextInfo
- information about the static context item type and posturereasons
- (optionally null) an array to which explanations of non-streamability should be appended- Returns:
- the posture and sweep of the expression
-
isChildlessNodeKind
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
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 convertedconfig
- 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 posturereasons
- 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
-
getSweep
-
getPostureAndSweepIfKnown
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
-
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
Return the wider of two sweeps. The order of increasing width is MOTIONLESS, CONSUMING, FREE_RANGING.- Parameters:
a
- the first sweepb
- the second sweep- Returns:
- the wider of the two
-
isIncrementalPosture
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
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
-