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 29805 - [XSLT30] Allow xsl:source-document/@use-accumulators to be present when streamable=no
Summary: [XSLT30] Allow xsl:source-document/@use-accumulators to be present when strea...
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 (show other bugs)
Version: Candidate Recommendation
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: 2016-09-02 16:47 UTC by Abel Braaksma
Modified: 2016-09-09 21:24 UTC (History)
0 users

See Also:


Attachments

Description Abel Braaksma 2016-09-02 16:47:55 UTC
(I raised this bug following the discussion thread in https://lists.w3.org/Archives/Public/public-xsl-wg/2016Sep/0003.html.)

Following up on yesterday's telcon discussion, I changed my mind on my standpoint and would like to propose that we lift the requirement that xsl:source-document/@use-accumulators cannot be used together with xsl:source-document/@streamable=no.

I would expect the semantics to behave as if

<xsl:source-document href="x.html" streamable="no" use-accumulators="a b">
   <!--sequence constructor-->
</xsl:source-document>

is equivalent to:

<xsl:source-document href="x.html" streamable="yes" use-accumulators="a b">
   <xsl:variable name="source" select="copy-of(.)" />
   <xsl:for-each select="$source">
      <!--sequence constructor-->
   </xsl:for-each>
</xsl:source-document>

This would work, because fn:copy-of on a streamed document copies its accumulators and disallows the use of any other accumulator. For non-streaming processors, it works because they are required to enforce the rule on copying and using applicable accumulators.
Comment 1 Abel Braaksma 2016-09-04 11:45:16 UTC
If the proposal is accepted, we should also update the requirement that @use-accumulators only applies to streamed accumulators:

"The value #all indicates that all accumulators that are visible in the containing package and declared with streamable="yes" are applicable."

and:

"Every EQName in the list must be the name of an accumulator, visible in the containing package, and declared with streamable="yes"."
Comment 2 Michael Kay 2016-09-07 22:55:29 UTC
I think there is a problem with making accumulators on unstreamed documents selectively applicable, which is that several instructions/functions can return the same document.

For example, if the stylesheet does

<xsl:variable name="x" select="doc('one.xml')"/>

and then does

<xsl:source-document href='one.xml' use-accumulators="a b c"/>

then I really don't want to have to keep two copies of the document one with accumulators and one without.

So I'm inclined to stay with the principle that accumulators are selectively applicable to streamed documents, but universally applicable to unstreamed documents, despite the lack of orthogonality.
Comment 3 Abel Braaksma 2016-09-08 08:34:56 UTC
Perhaps that is the way to go (re: comment#2), but how does that relate to the following? This example also requires keeping two copies around.

<xsl:variable name="x" select="doc('one.xml')"/>

<xsl:template name="xsl:initial-template">
   <!-- applies accumulators selectively -->
   <xsl:source-document streamable="yes" href='one.xml' use-accumulators="a b c">
      <!-- copies accumulators, other accumulators are invalid -->
      <xsl:apply-templates select="copy-of(.)" />
   </xsl:source-document>
   <!-- same document, but all accumulators are applicable -->
   <xsl:apply-templates select="$x" />
</xsl:template>

<!-- matches only $x? -->
<xsl:template match="x[accumulator-before('foo') = 'test']">
   <xsl:value-of select="accumulator-after('bar')" />
</xsl:template>

<!-- matches both $x and copy-of?-->
<xsl:template match="x[accumulator-before('a') = 'test']">
   <!-- error on copy-of, succeeds on $x? -->
   <xsl:value-of select="accumulator-after('bar')" />
</xsl:template>


The above is how the current rules are written up. That is, fn:copy-of() by default copies the accumulators and disallows other accumulators to apply.

Perhaps we could copy the accumulators of @use-accumulators, but at the same time allow non-streaming accumulators to apply to all non-streaming nodes?
Comment 4 Michael Kay 2016-09-09 21:24:32 UTC
We decided that the use-accumulators attribute should apply to streamed as well as unstreamed documents.

These changes have been applied.