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 26513 - [XSLT30] Access to context item within streamed xsl:for-each-group
Summary: [XSLT30] Access to context item within streamed xsl:for-each-group
Status: CLOSED WORKSFORME
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Working drafts
Hardware: PC All
: 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-08-03 14:13 UTC by Michael Kay
Modified: 2014-08-03 18:25 UTC (History)
0 users

See Also:


Attachments

Description Michael Kay 2014-08-03 14:13:49 UTC
Consider

<xsl:for-each-group select="x" group-by="@y">
  <a b="{@b}"/>
  <xsl:copy-of select="current-group()"/>
  <a b="{@b}"/>
</xsl:for-each-group>

This is streamable according to current rules.

During evaluation of xsl:for-each-group, the context item is the FIRST item in the group. So both references to @b access the b attribute of the FIRST x element. Clearly, after processing current-group(), we are no longer positioned on the first x element so we can only achieve this by remembering details of the x element (or perhaps by evaluating the post-descent instructions before we process the group, and remembering the result). So it can't be done without buffering.

I think we should (somehow) ban inspection access to the context item in the post-descent phase of a streaming xsl:for-each-group.
Comment 1 Michael Kay 2014-08-03 18:25:06 UTC
I should of course have used group-adjacent rather than group-by.

I added a test case si-group-027, and rather to my surprise, Saxon passes it. It seems that it does so by retaining enough information about the context item to evaluate inspection expressions for the duration of the group: that it it retains the context-item's start tag and ancestor stack. This seems acceptable within the definition of streaming. I'm therefore withdrawing the bug.