edu.UCL.xmiddle.lib.treediff
Class LevelTreeDiff

java.lang.Object
  |
  +--edu.UCL.xmiddle.lib.treediff.LevelTreeDiff

public class LevelTreeDiff
extends java.lang.Object

LevelTreeDiff computes the difference of two DOM trees using a simple, restricted algorithm. The algorithm detects the following modifications:

This algorithm compares two DOM trees on a level basis. For example, it will not handle the following scenario in the simplest way: Change <X><Y/></X> to <X><X><Y/></X></X> This modification has inserted a new level of nesting. This case will still be handled correctly by the algorithm, however the following modification list will be produced: Remove the Y element from the first X element, add a subtree of the form <X><Y/></X> to the first X.

In a nutshell, the tree algorithm will deal with any change correctly, however it may produce results that are longer than necessary. Look at testsuite/swap2.xml for an example.

CAUTION: Be extremely careful when changing properties of this algorithm. Because of the way this algorithm operators, merging can be done on the base tree without making a copy, and the difference operators can be applied in a linear order. Be sure to retain this property when modifying the algorithm.


Constructor Summary
LevelTreeDiff()
           
 
Method Summary
static org.w3c.dom.Document compute(org.w3c.dom.Document base, org.w3c.dom.Document changed)
          Compute is the main function of LevelTreeDiff which computes the difference of the two arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LevelTreeDiff

public LevelTreeDiff()
Method Detail

compute

public static org.w3c.dom.Document compute(org.w3c.dom.Document base,
                                           org.w3c.dom.Document changed)
Compute is the main function of LevelTreeDiff which computes the difference of the two arguments.

Parameters:
base - the DOM Document containing the base tree
changed - the DOM Document containing the tree with changes made
Returns:
the Document containing the difference tree, the format of which is specified in treediff.dtd.