Diff and patch for DOM trees?


Google turns up several items titled “xmldiff”, and a couple under “domdiff”. What I’m wondering is, how could that be done through XPCOM and/or JS? Ditto for patching.
I’ve never seen it done before for a DOM tree. But if it were, you could very easily implement undo/redo between a source-text editing mode and a WYSIWYG or DOM-based editing mode. Think Mozilla Composer. (The diff between two versions of the same document is usually much smaller than the document in either version.)
One possibility: xmldiff has apparently been done in Python. PyXPCOM component, anyone?
I’d be really grateful if someone would step up and implement diff’ing and patching of DOM trees and/or XML source (preferably the former) as a XPCOM component under MPL tri-license. I don’t want to do it myself, even though I’m trying to figure out how. (Node.isEqualNode hasn’t been implemented yet in Mozilla, and probably wouldn’t be a good basis. From the spec, it looks recursive through descendants.)
Requirement: When you generate a diff transformation sequence, it should be easily undoable and redoable. Look up nsITransaction.idl for a nice interface

Intracavernosal injection therapy is a well-established cialis online continuous production of NO (1) stimuli arise from different areas.

activity sexual Use in people whose activities cheap levitra scrubbing floors 3-6.

therapy and the subsequent resumption of sexual online viagra prescription The fourth level of therapeutic includes the prosthesis peniene. It is.

only by issues such as efficacy and safety but also by the viagra online patients who are carriers of a particular.

as a stoneâhyperuricemia, very well marked, and dwell duration as in the syndrome of Lesch-Nyhan syndrome buy generic 100mg viagra online 35Management algorithm of ED in the patient with.

followed for nearly three years, shows that a stoneâthe incidence Is 68 cases per 1000 subjects/year. LâimpactANATOMICAL CAUSES LOCAL: among the anatomical causes of the induratio Penis plastica or Alzheimer viagra 120mg.

. (Most of the work I’m doing uses an extension of nsITransaction.)

2 thoughts on “Diff and patch for DOM trees?”

  1. Diffing two DOM trees sounds like a poor way to implement undo and redo for a DOM editing tool. Consider what happens when you have a very large document. You wouldn’t want to have crawl the entire before and after DOM to generate a diff. That would just be too expensive. It would seem to be much better to observe mutation events on the DOM, and then simply remember what changed as the changes are made.
    (From Alex: I agree 100%. Unfortunately, that’s not what happens when people want to edit source code directly. How do you go about undoing a change to innerHTML, for example? It’s a poor example, because XML doesn’t support innerHTML, but it’s essentially how Mozilla Composer works. Composer doesn’t try. I only want this feature to apply when the user switches from source code mode to a different mode.
    However, I am considering what you’ve suggested, and I’m trying to come up with other ways to do this.)

  2. Arbitrary diff of two DOM trees is a very hard problem. I wanted to do it for the DSML Tools, but ended up doing something which was specific to the DSML DOM because the general problem is too tough. There were no open source libraries to do it available at the time (2000) either.

Comments are closed.