Home
Categories
Dictionary
Download
Project Details
Changes Log
What Links Here
License

Algorithm



For each node at the left (resp. the right), the tool will look for the corresponding node to the right (resp. the left). The status for each node can be:
  • There is no corresponding node at the right (resp. the left
  • The corresponding node is updated
  • The corresponding node is identical

It is possible to configure the comparison between the trees to specify when two nodes are considered identical.

General behavior

The rules walk the tree, and for each node at the left, try to find the corresponding node at the right. The node at the right which will be picked is the first node which is a child of the same parent as the node to compare[1]
See #extension_of_the_searchfor more information
.

Default comparison

Main Article: Default comparison

A default comparison will be used if no Rules configuration is defined.

Node name

Two nodes which don't have the same node name will be considered as different regardless of the rule.

For example, here no nodes will be found at the right for the node_1 node at the left, regardless of the attributes of the nodes:
  • root
    • node_1
  • root
    • node_2

Specificity for the root node

The corresponding root node for the left tree will always be found as the root node at the right tree. If the names of the nodes are different, the state will be considered as updated.

For example the root_1 and root_2 root nodes will be considered as updated:
  • root_1
    • node_1
  • root_2
    • node_1
The tool limit the search to children of the parent node in the right tree.

For example, if you have the following left and right nodes (supposing each node has no atributes), the child_2 node will be found because it is the same node in the left tree as in the right tree. As it is exactly the same node, if will be considered identical:
  • root
    • parent
      • child_1
      • child_2
  • root
    • parent
      • child_1
      • child_2
In the next example, there are two child_1 node at the right, the first one will be picked:
  • root
    • parent
      • child_1
      • child_2
  • root
    • parent
      • child_3
      • child_1
      • child_1
In this third example, the child_2 node will be found because it is a child of the same parent node in the right tree, even if it is not in the sam position in the parent node. Depending on the configuration, the node will be considered as identical or updated:
  • root
    • parent
      • child_1
      • child_2
  • root
    • parent
      • child_2
      • child_1
In the last example, the child_2 node will not be found because it is a child of another parent node in the right tree:
  • root
    • parent
      • child_1
      • child_2
  • root
    • parent
      • child_1
      • child_3
    • parent_2
      • child_2

Children of not found nodes

If the corresponding right node was not found for a parent node in the left tree, all children nodes will be considered as not found too. 5

For example, here parent_1 was not found in the right tree, so all the children of parent_1 will not be found too:
  • root
    • parent_1
      • child_1
      • child_2
  • root
    • parent_2
      • child_1
      • child_2

Rules configuration

Main Article: Rules configuration

The configuration of the comparison is specified in an XML file which defines:
  • On which condition two XML nodes can be considered as representing the same element
  • On which condition two XML nodes can be considered as updated

Note that two nodes which don't have the same node name will be considered as different regardless of the rule.

Notes

  1. ^ See #extension_of_the_searchfor more information

See also


Categories: core

xmldiff Copyright (c) 2024 Herve Girod. All rights reserved.