Merging SVG with DeltaXML
This page illustrates how DeltaXML provides the ability to merge XML documents, illustrated using Scalable Vector Graphic (SVG) files. Because SVG is pure XML, DeltaXML can determine the changes between two SVG files and generate a full context delta file. This file has all the common data required by both files and the changes represented in XML. By processing this file, we can create a new SVG file that represents the combination of the content of the two files.
We begin with two variations of the tiger graphic.
|
The First Tiger |
The Second Tiger |
|---|---|
|
Below the first tiger is displayed below. Note that |
In the second tiger, we have a full set |
|
|
|
|
View/Download: |
View/Download: |
Merging the Tigers
We now merge the tigers using DeltaXML. The DeltaXML Core engine performs an intelligent comparison of the two SVG files and determines where the graphics elements are unchanged and where changes have occurred. Elements that are present in either one or in both files will be present in the merged file, and if there are any conflicts these are by default handled by using the value in the second file (though clearly in production use this is controllable). Thus the yellow teeth of the first tiger are overridden by the correctly colored teeth in the second file.
The result of the merge is a better-looking tiger with a full set of teeth and whiskers.
|
The Merged Tiger |
|---|
![]() |
|
View/Download: tiger-merge.jpg / tiger-merge.svg |
Applications of Merge
This short demonstration shows the potential for merging graphical objects in SVG by operating at the XML level. DeltaXML is performing a comparison at the XML level and not at the graphical level, generating a full context delta which is an XML document containing both old and new graphics in a single file. This can be processed to generate a merged SVG file. In this example we have simply performed the merge, but it would also be possible to add animation or color coding to show which graphical elements have been merged in from the two files.
The merge can be performed on any XML data, whether it represents graphics, as here, or documents or data. The merge is XML-aware and merges the XML trees intelligently. Complex graphics, data and documents can therefore be merged.
The final step is to work with not two but three documents - synchronization.


