The XML Diff Language (XDL) uses path descriptors to identify the nodes in the source XML document. Path descriptors work on DOM data model, and use the node position as the core identifier for the nodes. XDL does not use XPath because the XPath data model differs from DOM.
All path descriptors refer to the original source XML tree before any changes are applied. So when the path descriptor applies to the first node of the source tree, which has been changed to be the third node in the changed tree, the path descriptor for this node is "1" as the node is first in the source document (the source document is a base).
The XDL Diffgram shows what nodes have been modified, added, or removed. It uses the words change, add, or remove inside the XDL to describe the change. Next, it describes what node the changes took place on, by giving a path descriptor, and then indicates what the changes were.
Here is the formal grammar used by the path descriptors.
Attribute :== '@'Name
NodePosition ::= Digit+
AttributeList :== Attribute ( '|' Attribute )*
PathDescriptor ::= NodeList | AttributeList
NodeList ::= RelativeNodeList | AbsoluteNodeList
RelativeNodeList ::= NodeInterval ( '|' NodeInterval )*
AbsoluteNodeList ::= '/' (NodePosition'/')* RelativeNodeList
NodeInterval ::= NodePosition | NodePosition '-' NodePosition
The following table shows some examples of path descriptors, and provides an explanation of the path descriptors.
|Example path descriptor||Explanation|
|3||Means the third child node of the current node.|
|1-2||Means the first and second child of the current node.|
|1-2|5||Means the first, second, and fifth child of the current node.|
|/1/2||Means the second child of the first node at the root level.|
|1/2/3-6||Means the third, fourth, fifth, and sixth child of the second child of the first node at root level.|
|@value||Means the attribute named
|@value | @type||Means the attribute named
The path descriptors are used in the XDL Diffgram to identify nodes in the original document. The XDL Diffgram contains elements qualified with the
xd: prefix associated with the namespace http://schemas.microsoft.com/xmltools/2002/xmldiff. The XDL Diffgram element names indicate what action has occurred (for example
change). The attributes of the XDL Diffgram element and the element content then specifies the details of the operation, for example which nodes are affected, new values of the nodes, and so on.
XML Diff Functionality | XML Diff Language (Diffgram) | XmlDiff Operation xd:node | XmlDiff Operation xd:add | XmlDiff Operation xd:remove | XmlDiffOperation xd:change | Extended Operations | Example of a Diffgram |XmlDiff Class