<?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>29712</bug_id>
          
          <creation_ts>2016-06-29 09:27:32 +0000</creation_ts>
          <short_desc>[xslt3.0] Why are streamable stylesheet functions required to be consuming?</short_desc>
          <delta_ts>2016-10-06 18:42:17 +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>Candidate Recommendation</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="Michael Kay">mike</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          <cc>abel.braaksma</cc>
          
          <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>126853</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-06-29 09:27:32 +0000</bug_when>
    <thetext>For streamability categories absorbing, shallow-descent, and deep-descent, we require the function body to be consuming. Is there any reason why we don&apos;t also allow it to be motionless?

This restriction requires the user to have a very good understanding of the circumstances under which expressions are consuming vs motionless. For example:

&lt;xsl:function streamability=&quot;absorbing&quot;&gt;
  &lt;xsl:param name=&quot;n&quot; as=&quot;node()&quot;/&gt;
  &lt;xsl:sequence select=&quot;exists($n/@*) or exists($n/*)&quot;/&gt;
&lt;/xsl:function&gt;

is allowed, but

&lt;xsl:function streamability=&quot;absorbing&quot;&gt;
  &lt;xsl:param name=&quot;n&quot; as=&quot;node()&quot;/&gt;
  &lt;xsl:sequence select=&quot;exists($n/@*) or has-children($n)&quot;/&gt;
&lt;/xsl:function&gt;

is not, because has-children() is motionless.

I can&apos;t think of any other cases where we allow an expression to be consuming and don&apos;t also allow it to be motionless.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126854</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-06-29 09:30:56 +0000</bug_when>
    <thetext>And if the argument is that it&apos;s easy enough to change the value of the streamability attribute to &quot;inspection&quot; in such cases, that&apos;s not true if you are overriding an absorbing function - the overriding function has to have the same streamability category.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126873</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-06-30 21:10:25 +0000</bug_when>
    <thetext>Note, markup in the spec suggests that this was a conscious decision, made somewhere in the course of the extensive debate on bug #27571.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126877</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-07-01 08:24:58 +0000</bug_when>
    <thetext>Another observation: perhaps the concern is about how the implementation copes with the situation where the function doesn&apos;t consume the input. But it has to deal with that situation anyway. For example the function body might be

if (current-date() &lt; xs:date(&apos;2000-01-01&apos;) 
then sum($input/@value)
else 0

which has consuming sweep (the wider of the sweeps of the two conditional branches), but doesn&apos;t actually consume anything.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126883</commentid>
    <comment_count>4</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-07-02 08:08:53 +0000</bug_when>
    <thetext>ACTION 2016-06-30-003: ABr to review bug 29712 in detail and determine whether changing the rule would lead to inconsistencies or implementation issues.

I&apos;ve been over previous mail and earlier bugs. I could recollect that we removed the ability for variants of resulting posture (a filter must be striding, grounded is not allowed). I can&apos;t recollect we did the same consciously for the sweep of the body of the function.

I see no problem in allowing this and agree to Mike&apos;s assessments in the previous comments.

A processor could, if they want, raise a warning, telling users they should use there resources more carefully and choose inspect instead of absorb.

This does raise a related question though: why don&apos;t we make our lives a bit simpler w.r.t. the rules. Some rules in this section would, for instance, be a bit easier if we force users to use a type signature of U{N} for the return types of filter, shallow-descent and deep-descent (the rules already require the function body to return nodes).


(In reply to Michael Kay from comment #3)
&gt; if (current-date() &lt; xs:date(&apos;2000-01-01&apos;) 
&gt; then sum($input/@value)
&gt; else 0
&gt; 
&gt; which has consuming sweep (the wider of the sweeps of the two conditional
&gt; branches), but doesn&apos;t actually consume anything.
The wider of the sweeps here is dependent on the type of the parameter (does it accept more-than-one?), which can then be either consuming or motionless.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126943</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-07-10 17:25:18 +0000</bug_when>
    <thetext>It&apos;s not strictly true that the rules for filter, shallow-descent, and deep-descent require the function to return nodes; they require its posture to be striding or crawling, but an expression such as

(child::x, 23)

is striding even though its result includes non-nodes. So I&apos;m inclined not to add a rule requiring the type signature of these functions to declare a return type of U{N}.

Apart from this, the WG approved the change to allow the function body to be motionless, and I have applied that part of the change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127015</commentid>
    <comment_count>6</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-07-21 14:08:51 +0000</bug_when>
    <thetext>&gt; (child::x, 23)
Isn&apos;t that also U{N}? 

But I agree, the change wouldn&apos;t fix anything. The rationale was it would make parts of the rules more readable. But we already use &quot;type adjusted posture and sweep&quot; in some of the rules, which comes down to the same (if the result type is xs:string, the posture will be grounded, even on an expression like x/y/z).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>127024</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-07-21 16:50:00 +0000</bug_when>
    <thetext>The WG accepted the proposal to allow the function body to be consuming, but did not accept the suggestion in comment #4 to place a restriction on the function type signature.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>