<?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>29141</bug_id>
          
          <creation_ts>2015-09-23 12:46:36 +0000</creation_ts>
          <short_desc>[XSLT30] fn:snapshot and fn:copy-of talk about node (singular), where the signature allows nodes</short_desc>
          <delta_ts>2015-10-29 12:42:26 +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>Last Call drafts</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="Abel Braaksma">abel.braaksma</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>123291</commentid>
    <comment_count>0</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2015-09-23 12:46:36 +0000</bug_when>
    <thetext>In 18.3, the summary text of fn:copy-of says:

    &quot;Returns a deep copy of the node supplied as the $node argument, or of 
    the context node if the argument is absent.&quot;

I think this should be &quot;deep copy of the nodes&quot; and &quot;as the $nodes argument&quot;.

In 18.4, the summary text of fn:snapshot says:

    &quot;Returns a copy of a node together with its ancestors and descendants and 
    their attributes and namespaces.&quot;

I think this should be &quot;Returns a copy of a sequence of nodes&quot;.

The body of the text has:

    &quot;The function returns a sequence of nodes in which each node is a 
    snapshot of the corresponding node in the input sequence supplied as the 
    argument $node. If the argument is an empty sequence, the function 
    returns an empty sequence.&quot;

This should be &quot;supplied as the argument $nodes&quot;, according to the signature.

The function used to explain its workings has a return type of &quot;node()?&quot;, this should be &quot;node()*&quot;:

    &lt;xsl:function name=&quot;fn:snapshot&quot; as=&quot;node()?&quot; new-each-time=&quot;maybe&quot;&gt;

should then become

    &lt;xsl:function name=&quot;fn:snapshot&quot; as=&quot;node()*&quot; new-each-time=&quot;maybe&quot;&gt;

The body of the function already allows a sequence of nodes to be returned.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123301</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-09-23 20:58:29 +0000</bug_when>
    <thetext>Yes, the change to make these functions work on sequences of nodes was clearly only implemented partially.

John Lumley also points out that we ought to be clear in the case where the same node is present more than once in the input sequence whether the output sequence will also contain the same node more than once, or whether each gets a different copy, or whether this is implementation-dependent. In keeping with the use of new-each-time=&quot;maybe&quot;, I think it should be implementation-dependent. 

More complex scenarios are also possible, where the input sequence to copy() or snapshot() contains a node N and also one or more of its ancestor or descendant nodes. We could either allow the result to contain overlapping copies in this case, or we could insist that in the result of copy-of, each node is parentless and siblingless, and in the result of snapshot, each node is siblingless (which would imply multiple copies).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123303</commentid>
    <comment_count>2</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2015-09-24 07:55:22 +0000</bug_when>
    <thetext>(In reply to Michael Kay from comment #1)

&gt; More complex scenarios are also possible, where the input sequence to copy()
&gt; or snapshot() contains a node N and also one or more of its ancestor or
&gt; descendant nodes. We could either allow the result to contain overlapping
&gt; copies in this case, or we could insist that in the result of copy-of, each
&gt; node is parentless and siblingless, and in the result of snapshot, each node
&gt; is siblingless (which would imply multiple copies).

You mean as in:

copy-of(.. | .)

to return only the parent, as it already includes the current node? I think as presently written, it returns a deep copy of the parent and a deep copy of the current node, both being parentless. I think snapshot() should work the same way.

Which is in line with applying templates with on-no-match=&quot;deep-copy&quot;.


(In reply to Michael Kay from comment #1)
&gt; John Lumley also points out that we ought to be clear in the case where the
&gt; same node is present more than once in the input sequence whether the output
&gt; sequence will also contain the same node more than once, or whether each
&gt; gets a different copy, or whether this is implementation-dependent. In
&gt; keeping with the use of new-each-time=&quot;maybe&quot;, I think it should be
&gt; implementation-dependent. 

I agree, it should be implementation-dependent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123304</commentid>
    <comment_count>3</comment_count>
    <who name="Abel Braaksma">abel.braaksma</who>
    <bug_when>2015-09-24 08:03:46 +0000</bug_when>
    <thetext>Does it make sense (and isn&apos;t it too big a change) to allow any sequence as input to copy-of() and snapshot(), where in the case of atomic values, it is simply a no-op? Apart from the signature, I don&apos;t think the rules have to change.

I think it makes things simpler, i.e. it would help with generic scenarios where input can be anything, and users won&apos;t have to write the following, which seems silly:

&gt; if($input instance of node()) then copy-of($input) else $input

It also helps with making streaming xsl:merge behave more stable and less surprising in the event the xsl:merge-source/@select selects non-nodes or a mix of nodes and atomic values (see bug 29142)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123331</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-09-28 10:18:00 +0000</bug_when>
    <thetext>In response to comment #2, I think the question is, what can we say about the following expressions:

(a) count($X) eq count(copy-of($X))

(b) every $x in copy-of($X) satisfies empty($x/..)

(c) let $R := copy-of(.., .) return $R[1] is $R[2]/..

I think (a) should always be true (for any input $X)

On balance I think (b) should always be true (i.e. all nodes in the result are parentless)

That would mean that (c) is false: although you&apos;ve already copied &quot;.&quot; in the course of copying &quot;..&quot;, you have to copy it again when processing the second item in the input sequence, because the first copy wasn&apos;t parentless.

In response to comment #3, although one could specify copy-of and snapshot to be no-ops when applied to atomic values or functions, I don&apos;t think it&apos;s useful enough to justify a spec change at this stage.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123616</commentid>
    <comment_count>5</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-10-08 16:58:19 +0000</bug_when>
    <thetext>In discussion we were inclined to propose:

* copy-of follows the same rules as xsl:copy-of

** therefore it accepts items of any kind

** copy-of($seq) delivers the same result as $seq!copy-of(.), that is, each item is copied independently; if the same node appears twice you get two different copies; all nodes in the result are parentless

** snapshot, similarly, accepts items of any kind</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123640</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-10-09 19:57:43 +0000</bug_when>
    <thetext>The changes were approved and have been applied.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>123862</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2015-10-22 19:32:40 +0000</bug_when>
    <thetext>Some minor improvements to the stylesheet were suggested in email and have been incorporated.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>