Bug #5529


Streaming: effect of "/" versus "!"

Added by Michael Kay 7 months ago. Updated 5 months ago.

Start date:
Due date:
% Done:


Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:


Test case sx-intersect-313

This may be a problem in the spec rather than in the Saxon implementation.

The expression (A intersect B) / (.+1) is streamable, while (A intersect B) ! (.+1) is not. This seems unreasonable, since they are obviously equivalent.

Actions #1

Updated by Michael Kay 7 months ago

Similarly, (test case sx-intersect-315)

<xsl:for-each select="A intersect B">
  <xsl:value-of select=".+1"/>

is not streamable (unsurprisingly, since it is internally the same as the formulation using "!")

Actions #2

Updated by Michael Kay 7 months ago

An observation: the spec says that given the expression (A § B) where § is union, intersect, or except, then if A and B are both striding, the result is crawling.

This is legitimate in the case of union, because for example (A/B union */*/C) can contain two nodes where one is an ancestor of the other. But it is unnecessarily restrictive for intersect and except, because with these operators, every node in the result is present in the value of the LH operand, and therefore if the LH operand is striding (contains no nested nodes) then the result is striding as well.

For union, we can make the result striding if the two operands have the same "constant depth" (the number of child selections). But the spec doesn't have the machinery to calculate the "constant depth" of an expression. In Saxon we possibly do, in the form of the path maps used for analysis of XQuery projection.

Actions #3

Updated by Michael Kay 5 months ago

Added issue against the spec:

Actions #4

Updated by Michael Kay 5 months ago

As regards the original problem, there is in fact a reason for the distinction: "/" forces the results into document order, while "!" does not. This means that the expression with "/" is a "scanning expression" - it can be evaluated using a scan in document order, testing each node against the expression treated as a pattern.

I propose that we change the rules for (A intersect B) (and likewise (A except B) so that the result is striding if A is striding; and this is likely to make use of "!" acceptable in many cases.

Please register to edit this issue

Also available in: Atom PDF