This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 24651 - Streamability rules of accumulator-before/after do not help with dependency on current node
Summary: Streamability rules of accumulator-before/after do not help with dependency o...
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Last Call drafts
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-13 11:10 UTC by Abel Braaksma
Modified: 2014-07-14 10:54 UTC (History)
0 users

See Also:


Attachments

Description Abel Braaksma 2014-02-13 11:10:39 UTC
Related to bug 24650 and bug 24649.

The operand usage of the only argument of the functions fn:accumulator-before and fn:accumulator-after is Navigation[1]. The text says this is to make it independent of the current node.

Hence we cannot write this:

<xsl:value-of select="accumulator-after(@foo)" />

because a climbing posture in a navigation context is disallowed. However, we can write this:

<xsl:value-of select="accumulator-after(string(@foo))" />

which removes the problem with Navigation (the result of string() is grounded, not climbing), but does not remove the dependency on the current node.

Considering that the type of the first argument is xs:string (and provided that the resolution to bug 24560 is not equal to changing this), the argument will be atomized, hence there is no need for setting the operand usage to Navigation, because there is no way to navigate away from it.

[1] http://www.w3.org/TR/xslt-30/#streamability-fn-accumulator-after
Comment 1 Michael Kay 2014-03-21 11:31:47 UTC
The WG examined this problem on 2014-03-20.

Section 18.2.7 establishes that accumulator-before can only be called in a pre-descent instruction, and accumulator-after can only be called in a post-descent instruction. This rule has the consequence that the argument to these two functions cannot be consuming. However, there is no intrinsic reason why it should not be climbing.

I propose therefore to:

(a) reclassify the argument as having usage absorption

(b) point out in 19.8.8.1 and 19.8.8.2 that it is a consequence of 18.2.7 that the argument cannot be consuming

(c) fix the error in 18.2.7 which suggests that accumulator-before and accumulator-after can only be called in streamable template rules. They can also be called within xsl:stream, and in fact I see no reason to disallow their use within xsl:for-each or xsl:iterate. 

Specifically, in 18.2.7

(i) Delete the paragraph

The pre-descent accumulator function accumulator-before can only be invoked in the course of evaluating a pre-descent instruction in a template rule that matches the context item, and the post-descent accumulator function accumulator-after can only be invoked in the course of evaluating a post-descent instruction in such a template rule. The concepts "pre-descent instruction" and "post-descent instruction" are defined in 19.8.3 Classifying Sequence Constructors.

(ii) delete the paragraph (and sub-paras)

If a call on accumulator-before or accumulator-after is evaluated for a streamable accumulator then:

The evaluation must occur in the course of evaluating a pre-descent or post-descent instruction in some streamed template rule T, respectively
The context item at the point of invocation of the accumulator function must be the same as the context node for T.

and replace the first of these with:

It is a dynamic error if accumulator-before or accumulator-after is evaluated when the context item is not a node.

When accumulator-before or accumulator-after is evaluated, at least one of the following conditions must be true, otherwise a dynamic error [TBA] is signaled:

* The context node is grounded
 
* The accumulator is declared with streamable=yes, and one of the following is true:

** The function is accumulator-before and the call is evaluated in the course of evaluating a *pre-descent instruction* whose context item is the same as the context node for evaluation of the function

** The function is accumulator-after and the call is evaluated in the course of evaluating a *post-descent instruction* whose context item is the same as the context node for evaluation of the function

Change the definitions of pre-descent and post-descent instructions slightly in 19.8.3 so that an instruction is classified as pre-descent or post-descent only if it is a descendant of an xsl:template element with streamable=yes, or an xsl:stream instruction.
Comment 2 Michael Kay 2014-03-21 16:45:14 UTC
Correction, we don't need to say this:

It is a dynamic error if accumulator-before or accumulator-after is evaluated when the context item is not a node.

because we already say it (error [XTTE3360]).
Comment 3 Michael Kay 2014-07-03 16:42:33 UTC
Noted that the above rules don't seem to generate a streamability problem if they conclude that accumulator-before or accumulator-after are consuming. We need to state that accumulator-before(child::element) isn't allowed.
Comment 4 Michael Kay 2014-07-11 16:23:02 UTC
The WG accepted the proposal in

https://lists.w3.org/Archives/Member/w3c-xsl-wg/2014Jul/0006.html

(member only)

To summarise:


1. If the argument to accumulator-after/before is motionless, the function call is grounded and motionless.

2. Otherwise, the function call is roaming and free-ranging.