<?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>13970</bug_id>
          
          <creation_ts>2011-08-30 12:53:55 +0000</creation_ts>
          <short_desc>[UPD] fn:put and transform expressions</short_desc>
          <delta_ts>2014-10-14 09:36:16 +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>Update Facility</component>
          <version>Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</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="Tim Mills">tim</reporter>
          <assigned_to name="Jonathan Robie">jonathan.robie</assigned_to>
          <cc>christian.gruen</cc>
    
    <cc>john.snelson</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>56039</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2011-08-30 12:53:55 +0000</bug_when>
    <thetext>Are there any special considerations when mixing fn:put with transform expressions?

Example 1
---------

copy $dummy := &lt;dummy /&gt;
modify fn:put(&lt;new-document /&gt;, &quot;output.xml&quot;)
return local:non-updating-query()

This stores an element in output.xml but also returns the result of executing a non-updating query.  

It seems a little unfortunate that this &apos;dummy&apos; is required to mix fn:put with a non-updating query - although since this is essentially an expression with side effects, perhaps that&apos;s no bad thing.

Example 2
---------

let $original := doc(&apos;update.xml&apos;)
return
  copy $doc := $original
  modify (insert node &lt;node /&gt; into $doc/nodes, fn:put($doc, &quot;update.xml&quot;))
  return $original

This example reads and writes the same resource.  In XSLT, there is a specific (recoverable) error which mentions a similar situation with xsl:result-document.

[ERR XTRE1500] It is a recoverable dynamic error for a stylesheet to write to an external resource and read from the same resource during a single transformation, whether or not the same URI is used to access the resource in both cases. 

Example 3
---------

copy $doc := doc(&apos;update.xml&apos;)
modify (insert node &lt;node /&gt; into $doc/nodes, fn:put($doc, &quot;update.xml&quot;))
return (count($doc/nodes/node), count(doc(&apos;update.xml&apos;)/nodes/node))

Because &apos;doc&apos; is stable the two calls to doc must return the same result, even though an update has occurred.

Example 4
---------

copy $doc := &lt;a /&gt;
modify (fn:put($doc, &quot;update.xml&quot;))
return doc(&apos;update.xml&apos;)

Does doc(&apos;update.xml&apos;) see the newly created resource, or the original resource (if we assume one was available)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78024</commentid>
    <comment_count>1</comment_count>
    <who name="Christian Gruen">christian.gruen</who>
    <bug_when>2012-11-08 00:04:25 +0000</bug_when>
    <thetext>Has there been any more discussion on this issue?

I would even suggest to completely disallow fn:put() functions inside transform expressions in order to reduce the chance of indeterministic, implementation-dependent behavior. For example, in the following example..

  copy $a := &lt;a/&gt; modify fn:put($a, &quot;1&quot;) return (),
  copy $b := &lt;b/&gt; modify fn:put($b, &quot;2&quot;) return ()

we will have no guarantee if $a or $b will be found in the final result.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>78033</commentid>
    <comment_count>2</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2012-11-08 07:17:41 +0000</bug_when>
    <thetext>The WG hasn&apos;t discussed bugs against XQuery Update 1.0 for quite some time due to a focus on XQuery 3.0.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81411</commentid>
    <comment_count>3</comment_count>
    <who name="Jonathan Robie">jonathan.robie</who>
    <bug_when>2013-01-15 17:41:21 +0000</bug_when>
    <thetext>The Working Group has decided that it is an error if the modify clause of a transform expression produces a upd:put primitive.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113076</commentid>
    <comment_count>4</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2014-10-14 09:18:52 +0000</bug_when>
    <thetext>I&apos;m reopening, as I&apos;m unable to find the agreed change in the XQuery Update 3.0 editor&apos;s draft.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>113082</commentid>
    <comment_count>5</comment_count>
    <who name="John Snelson">john.snelson</who>
    <bug_when>2014-10-14 09:36:16 +0000</bug_when>
    <thetext>I&apos;m closing this bug again, as the decision is recorded in changes.txt and will be made in the course of time.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>