Use of accumulator-before() call in select expression of xsl:value-of changes streamability analysis
Added by Martin Honnen about 7 years ago
When I use
in a streaming stylesheet with @Saxon-EE 9.8.0.4J@ from the command line it passes the streamability analysis and runs fine.
When I add a call to a streamable accumulator
Saxon assesses the construct as not streamable, complaining not about the accumulator use but saying
XTSE3430: Template rule is not streamable * There is more than one potentially consuming operand: {parent::(document-node()|element()) / @id} and {@data}, both on line 22 Template rule is not streamable * There is more than one potentially consuming operand: {parent::(document-node()|element()) / @id} and {@data}, both on line 22
Why are the two attribute uses suddenly potentially consuming operands?
Full stylesheet is
header-data,record-id,event-data
Sample input is
Code works fine when changing that template to
,
Replies (1)
RE: Use of accumulator-before() call in select expression of xsl:value-of changes streamability analysis - Added by Michael Kay about 7 years ago
If you run this with --strictStreamability:on, then it fails streamability analysis even without the call to accumulator-before(). That typically means that the unoptimized expression is non-streamable according to the W3C rules, but Saxon has done some rewrite in the course of optimization that makes it streamable. What it has actually done is to distribute atomization: @data(../@id, @data)@ has been turned into @(data(../@id), data(@data))@.
Somehow the addition of accumulator-before() has prevented the atomization being distributed in this way. The reason for this is that the type analysis hasn't been able to exclude the possibility that the accumulator-before function will be a sequence that includes text nodes, and so the expression tree includes an expression to merge adjacent text nodes, which disturbs the optimization of the atomizer.
With the expression in the original form @data(../@id, @data),@, we have a comma-expression with two operands, one of which is climbing and motionless, the other is striding and motionless. The operand usage of an operand in a comma expression is transmission, and both operands are therefore "potentially consuming" under the rule "An operand is potentially consuming if ... The operand usage is transmission and the operand is not grounded. ". The reason for this rule is that we can't immediately tell what the outer expression is doing with the result (as it happens, it is atomizing it, but this requires analysis beyond the scope of the W3C streamability rules).
Please register to reply