<?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>29990</bug_id>
          
          <creation_ts>2016-11-08 09:44:39 +0000</creation_ts>
          <short_desc>[XSLT30] result documents in temporary trees and in patterns as a result of fn:transform calls</short_desc>
          <delta_ts>2016-12-01 18:03:02 +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>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Abel Braaksma">abel.braaksma</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          <cc>josh.spiegel</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>128107</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-11-08 09:44:39 +0000</bug_when>
    <thetext>A FO31 bug 29959 comment#8 made me realize that we have carefully crafted rules for side-effects to *never* happen while evaluating patterns or temporary result trees.

But I don&apos;t think we ever imagined a function fn:transform, which is now part of FO31. Since use of functions is not restricted, one could write, for instance:

&lt;xsl:template match=&quot;foo/bar[fn:transform(....) = 12]&quot;&gt;
   ....
&lt;/xsl:template&gt;

If the transformation has a side effect, what would happen? This transformation could be evaluated once, never, many times, be cached, write messages, result documents, principal results etc.

I think we either may have to prohibit this, or make sure that result documents are not created in such cases (for instance by requiring that serialization be disabled in such execution contexts).

A similar thing applies to xsl:evaluate calling this function, or a dynamic function call effectively calling this function.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128108</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-11-08 11:44:57 +0000</bug_when>
    <thetext>The problem of fn:transform having side-effects (with the &quot;saved&quot; option) was discussed and resolved in the closure of bug #29951.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128110</commentid>
    <comment_count>2</comment_count>
    <who name="Josh Spiegel">josh.spiegel</who>
    <bug_when>2016-11-08 14:55:10 +0000</bug_when>
    <thetext>I think the decision to preserve &quot;saved&quot; (side-effects) in any form is objectively wrong.  It would, for example, be trivial to write valid tests that no reasonable implementation would pass.  Or, write tests where many reasonable implementations would produce completely different but valid results.  Or, more importantly, write tests where valid results are unintuitive to users.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128111</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-11-08 14:59:43 +0000</bug_when>
    <thetext>Then I suggest you (one of you) should reopen bug #29951 rather than opening new issues.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128114</commentid>
    <comment_count>4</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-11-08 16:06:18 +0000</bug_when>
    <thetext>I&apos;m not sure any F&amp;O resolution will remove the requirement to prohibit (or not?) the use of this function in cases where we have previously prohibited creating result documents.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128116</commentid>
    <comment_count>5</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-11-08 16:08:19 +0000</bug_when>
    <thetext>One way forward is, for instance, to require XSLT processors to raise FOXT0007 in such cases, normatively, so that it won&apos;t be an implementation-defined/dependent behavior.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128272</commentid>
    <comment_count>6</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2016-12-01 11:00:14 +0000</bug_when>
    <thetext>Update: the proposal in F&amp;O Bug 29951, comment#11 removes the problem of side-effects in temporary output state to an implementation-defined function.

The proposed solution is for fn:transform to call a function for each result document, which itself can be defined as an option to fn:transform. This function may or may not be implementation-defined and/or have side effects.

This in itself creates a peculiar situation: if called from an XSLT stylesheet, that stylesheet will *not* be able to save the results through such function (unless it uses implementation extensions), because a function call operates in a temporary output state.

A workaround would be to write stylesheets that return all result documents as part of the principal result.

Another workaround would be for XSLT to define an extra parameter for the $options of fn:transform, for instance to define a template, named output definition or mode, which receives the result. This would then in turn &quot;inherit&quot; the output state the call itself is in.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>128274</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-12-01 18:03:02 +0000</bug_when>
    <thetext>The WG decided this is fixed by virtue of the resolution to bug #29951</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>