Copying an Existing Node or Fragment to a New Position in the Tree

Microsoft XML Diff

Microsoft XML Diff 1.0 and XML Patch 1.0

Copying an Existing Node or Fragment to a New Position in the Tree

The XmlDiff tool distinguishes when a node has simply moved to a new position in the tree. When this occurs, the XDL Diffgram reports this as a pair of an add and a remove operation. The xd:remove operation is shown where the nodes have been moved from and the xd:add operation is where the nodes have been moved to. In this case, XDL has a special xd:add element with the match attribute specifying from where the nodes have been copied. It may also have a subtree attribute specifying whether whole subtree or just the root node has been copied.

For example, the following xd:add element indicates that the fifth and sixth child nodes of the first node, at the root level, have been copied at the current position in the source tree.

<xd:add match="/1/5-6"/>

The following table describes the attributes of the xd:add element when a fragment or node is moved to a new position in the tree.

Attribute name Data type Description
match path descriptor Absolute path descriptor evaluating to a set of nodes in the source XML document. The node set cannot contain attributes.
subtree bool An option indicating whether to copy the descendants of the nodes in the selected node set (copy whole subtrees) or not. Default is yes. If the value is no, then the match attribute must evaluate to a single node.
opid unsigned int Operation ID. The corresponding xd:remove operation has the same operation ID.

The following table describes the attributes of the xd:add element when a fragment or node is moved to a new position in the tree.

Content Description
(xd:add)* Child nodes of the new node (for element only) when the subtree option is no. Otherwise the content of the node must be empty.

See Also

XML Diff Functionality | XML Diff Language (Diffgram) | Path Descriptors | XmlDiff Operation xd:node | XmlDiff Operation xd:add | W3C DOM Node Types | Adding Fragments and Multiple Nodes | Extended Operations | XmlDiff Operation xd:remove | XmlDiff Operation xd:change | Example of a Diffgram | XmlDiff Class

© 2002 Microsoft Corporation. All rights reserved.