[Bug 26328] New: Streamable and non-streamable accumulators in grounded postures

https://www.w3.org/Bugs/Public/show_bug.cgi?id=26328

            Bug ID: 26328
           Summary: Streamable and non-streamable accumulators in grounded
                    postures
           Product: XPath / XQuery / XSLT
           Version: Last Call drafts
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLT 3.0
          Assignee: mike@saxonica.com
          Reporter: abel.braaksma@xs4all.nl
        QA Contact: public-qt-comments@w3.org

We briefly discussed this during the latest telcon of the WG. The issue is the
following, suppose you have the following in your stylesheet:

<xsl:mode streamable="yes" />
<xsl:mode name="non-streamable" />

<!-- counting nodes -->
<xsl:accumulator name="acc" 
   initial-value="()"
   streamable="yes">

   <xsl:accumulator-rule 
      match="node()"
      phase="start"
      new-value="$value + 1" />
</xsl:accumulator>

<!-- counting nodes non-streamable -->
<xsl:accumulator name="acc-ns" 
   initial-value="()"
   streamable="no">

   <xsl:accumulator-rule 
      match="node()"
      phase="start"
      new-value="$value + 1" />
</xsl:accumulator>

<xsl:template match="*">
   <xsl:value-of select="accumulator-before('acc')" />
   <xsl:choose>
      <xsl:when test=". instance of text()">
         <xsl:apply-templates
            select="copy-of(.)"
            mode="non-streamable" />
      </xsl:when>
      <xsl:when>
         <xsl:for-each select="copy-of(comment())">
            <!-- streamable accumulator? -->
            <xsl:value-of select="accumulator-before('acc')" />
            <!-- or non-streamable accumulator? -->
            <xsl:value-of select="accumulator-before('acc-ns')" />
         </xsl:for-each>
      </xsl:when>
   </xsl:choose>
</xsl:template>

<xsl:template match="text()" mode="non-streamable">
   <!-- streamable accumulator? -->
   <xsl:value-of select="accumulator-before('acc')" />
   <!-- or non-streamable accumulator? -->
   <xsl:value-of select="accumulator-before('acc-ns')" />
</xsl:template>

Streamable accumulators are defined such that they can only be used in
streamable contexts. The example above is a demonstration of the questions that
arise. I am unsure whether the current rules either prevent, or allow the use
of accumulators in grouned context or non-streamable modes called with copies
of nodes from a streamable document. 

I recognize the following situations:
1) calling a streamable accumulator when a streamed node, not copied, is the
context node (first call above).

2) calling a streamable accumulator when a copy of a streamed node is the
context node (inside the for-each above).

3) calling a streamable accumulator when a copy of a streamed node is the
context node and the construct is inside a declaration that is outside the
scope of streamability analysis (the last matching template above).

4) calling a non-streamable accumulator when a copy of a streamed node is the
context node (inside the for-each above)

5) calling a non-streamable accumulator when a copy of a streamed node is the
context node and the construct is inside a declaration that is outside the
scope of streamability analysis (the last matching template above).

In the specification (internal draft) we currently say under 18.2.1: 

"An accumulator is applicable to a particular document if the pattern supplied
in the applies-to attribute matches the first element node in the document
[...]"

We don't say anything, I think, about temporary documents. If we create a copy
of a node, are the accumulated values reset? Do both streaming and
non-streaming accumulators apply to it? Or should they turn up empty? Or does
the copy of a node include the accumulated values that have been calculated for
the in-scope nodes?

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Monday, 14 July 2014 12:53:53 UTC