> I'm looking for a tip as to how best to use the XXE api to solve the
> following problem.
> 
> Problem: I have two XML trees that are expected to be very similar. One
> is considered a baseline and the other is an update. I need to compare
> the two trees and discover what differences there are, where the
> expected results for any given node are as follows:
> 
> 1.    No change
> 2.    Node removed
> 3.    Node added
> 4.    Node modified
> 
> The modification of a node will generally mean a change to the text
> values of its leaf node children, but not changes of its branch node
> children. It seems that the event model could be exploited somehow to
> set client properties on nodes to indicate the type of change, but I'm
> not quite sure how best to go about it. I've been experimenting with
> document listeners. It seems a good solution would be to recursively
> compare and change the baseline tree until it matched the update tree
> and use a DocumentListener to record the changes, or perhaps use an
> UndoManager. Am I on the right track? Any help is much appreciated.

You are trying to solve a difficult problem for which we have no clear
answers yet.

There are two ways to implement what you want:

[1] Implement change tracking: that is, record somewhere the changes
made by the author by using a DocumentListener or a specialization of
UndoManager (which happens to implement DocumentListener).

[2] Use an XML Diff algorithm such as the patented algorithm sold by
DeltaXML. http://www.deltaxml.com/

We prefer [2]. If you find a published algorithm which works flawlessly
in the case of XML documents containing prose, do not hesitate to tell
us about this algorithm.




Reply via email to