Re: ACTION-2244: Remove the term deep copy

On Fri, 29 Mar 2019 18:28:23 +0100, Erik Bruchez <ebruchez@orbeon.com>  
wrote:

>> Of course, insert says:
>>
>> "Each node in the origin-sequence is cloned in the order it appears in  
>> the sequence."
>>
>> which may just have moved the problem to there, since we don't strictly  
>> define what "clone" means.
>
> Right, "clone" == "deep copy" ;)
>
> I am now a little puzzled that there is no simple formal definition in  
> any of the XML specs, although to be fair, XSLT doesn't work via  
> mutation but by producing new trees, >while here we have mutation.

I find this, which is rather straightforward, in XSLT 3:

https://www.w3.org/TR/xslt-30/#built-in-templates-deep-copy

"The effect of processing a tree using a mode that specifies  
on-no-match="deep-copy" is that an unmatched element in the source tree is  
copied unchanged to the output, together with its entire subtree."

In the same document, with rather more formality:

https://www.w3.org/TR/xslt-30/#copy-of

"The xsl:copy-of instruction can be used to construct a copy of a sequence  
of nodes, atomic values, and/or function items with each new node  
containing copies of all the children, attributes, and (by default)  
namespaces of the original node, recursively. The result of evaluating the  
instruction is a sequence of items corresponding one-to-one with the  
supplied sequence, and retaining its order."

... and then loads more text going through all the cases.

Steven

>
> The DOM has a `cloneNode(deep)` function. [1] However, reading it  
> doesn't exactly feels great, and I don't see a notion of in-scope  
> namespaces, for example.
>
> The actual logic is simple: all node properties must be preserved in a  
> deep copy, except that all the nodes have new identities. [2]
>
> -Erik
>
> [1] https://www.w3.org/TR/domcore/#dom-node-clonenode
> [2] https://www.w3.org/TR/xpath-datamodel/#node-identity

Received on Monday, 1 April 2019 08:36:57 UTC