Copies nodes in the first node-list expression (source nodes) to the destinations determined by the the location directive applied to nodes in the second node-list expression (target nodes). If the source node-list contains more than one node, than N'th node in the source node-list is copied to the location relative to the N'th node in the target node-list.
is used, then the target node-list expression
is evaluated in the context of the source node
Possible values for location are:
prepend. The first
three location directives cause making a copy of the source nodes
after, before, and within (as the last child-node) the target
replace location directive is used,
source node are copied before the respective
target nodes and target nodes are removed.
location directives allow,
depending on the destination node type,
either inserting copies of the
source nodes as the first or last child nodes of
a destination element or appending/prepending
destination node data in case of non-element destination nodes.
See location argument type
for more detail.
The command returns a node-list consisting of the copies of all source nodes created by the command.
Despite the fact the command is named "copy", nodes resulting from copying the source nodes may pass through certain type conversion before they are inserted at the appointed destinations. This, however, only happens in cases where the types of the source and target nodes are not compatible with the location directive. See location argument type for more detail.
Note that XSH2 refuses to create multiple top-level
move and similar commands.
Example 1. Replace living-thing elements in the document b with copies of the corresponding creature elements from the document $a.
copy $a//creature replace $b//living-thing
Example 2. Copy every element into itself
copy --respective $a//* into .
copy $a//* into $a//*#same as above