[xml] Suggestion for hacking

Date view Thread view Subject view Author view

From: Daniel Veillard (Daniel.Veillard@w3.org)
Date: Fri Oct 20 2000 - 12:37:32 EDT


  Okay here is a small tool which would be a good way to exercise
and spend a week-end hacking on libxml:
   - building an XML merge tool

  Lets call it xmlmerge, it's goal is to merge 2 XML files, i.e.
retain the common parts and insert the extra ones within the tree
common to both imput files, giving precedence to one of them.
For example:

--------------- first.xml ------------
<a>
   <b z="1">
   <c>
      <d/>
   </c>
   <f y="2">
   <g>
      <h/>
      <j>hello</j>
   </g>
</a>
--------------- second.xml ------------
<a>
   <b z="1" y="1">
   <e/>
   <f y="3">
   <g>
      <h>
         <i/>
      </h>
      <h>test</h>
      <j>bonjour</j>
   </g>
</a>
---------------------------------------

and the result of xmlmerge first.xml second.xml would be

---------------------------------------
<a>
   <b z="1" y="1">
   <c>
      <d/>
   </c>
   <e/>
   <f y="2">
   <g>
      <h>
         <i/>
      </h>
      <h>test</h>
      <j>hello</j>
   </g>
</a>
---------------------------------------

  Should not be that much of code, two xmlParseDoc then a recursive
function call doing a merge operation at each level on the first tree,
then an xmldocDump.
  Of course the core of the problem is the recursive function which
could be made more or less "intelligent" depending on how much context
is looked at before deciding to add or drop (and where).
  If I remember correctly people from IBM Alphawork did a very efficient
XML diff and presented a paper on it a couple of years ago. This would be
an interesting related lecture [1].

Daniel

[1] I actually easilly located it they do a merge too :-)
    http://www.alphaworks.ibm.com/tech/xmldiffmerge

-- 
Daniel.Veillard@w3.org | W3C, INRIA Rhone-Alpes  | libxml Gnome XML toolkit
Tel : +33 476 615 257  | 655, avenue de l'Europe | http://xmlsoft.org/
Fax : +33 476 615 207  | 38330 Montbonnot FRANCE | Rpmfind search site
 http://www.w3.org/People/all#veillard%40w3.org  | http://rpmfind.net/
----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Fri Oct 20 2000 - 12:43:39 EDT