<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>20981</bug_id>
          
          <creation_ts>2013-02-12 16:25:33 +0000</creation_ts>
          <short_desc>Why accumulators are not passed to xsl:evaluate?</short_desc>
          <delta_ts>2013-05-24 14:18:32 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XSLT 3.0</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Florent Georges">fgeorges</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>83010</commentid>
    <comment_count>0</comment_count>
    <who name="Florent Georges">fgeorges</who>
    <bug_when>2013-02-12 16:25:33 +0000</bug_when>
    <thetext>&quot;10.4 Dynamic XPath Evaluation&quot; &lt;http://www.w3.org/TR/xslt-30/#dynamic-xpath&gt; says that user-defined functions are part of the static context of the XPath expression to evaluate. But it excludes explicitly accumulators.

The reason why it does so is not clear.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83166</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-02-14 23:23:35 +0000</bug_when>
    <thetext>I think the rules may be over-restrictive.

In the absence of streaming on the accumulator, the only reason to have restrictions is the possibility of circularity (and dependence on order of evaluation) among multiple accumulators. But I don&apos;t think this is in principle different from allowing infinite recursion in ordinary function or template calls. So with an accumulator that specifies streamable=&quot;no&quot; we should lift restrictions.

With streaming on, an alternative design might be to say that if an accumulator function is called and the context node is not the current node in a streamed input document, then calling the accumulator function is allowed, but fails dynamically. This might lead to a simpler set of rules.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>83658</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-02-25 15:41:04 +0000</bug_when>
    <thetext>We&apos;ve generally had a rule that streamability must be determinable statically. If we relax the rules disallowing dynamic calls on accumulator functions, we lose this property. However, I think it may be worth doing.

Defining the dynamic rules is not entirely trivial, but I think it can be done using the concepts of pre-descent instructions and post-descent instructions in 19.3.3. Something like this:

If an accumulator function is called and the context item is a node in a streamed input document, then a dynamic error occurs if neither of the following conditions is true:

* the function is a pre-descent function and it is being invoked in the course of evaluating a pre-descent instruction in a template rule that matches the context item

* the function is a post-descent function and it is being invoked in the course of evaluating a post-descent instruction in a template rule that matches the context item

I think this approach would allow us to be a bit more flexible about evaluating accumulator functions while processing leaf nodes such as text nodes.

While we are about it, I&apos;m wondering if we need any special rules to prevent a reference to a streamed node appearing in the closure of a context-dependent function item.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>87778</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-05-16 15:12:43 +0000</bug_when>
    <thetext>See https://lists.w3.org/Archives/Member/w3c-xsl-wg/2013May/0006.html for proposed resolution</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88127</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-05-23 16:49:07 +0000</bug_when>
    <thetext>Proposal was accepted (with comments/observations).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88204</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-05-24 14:18:32 +0000</bug_when>
    <thetext>The proposed changes have been applied.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>