The UNIX pipeline is an elegant demonstration of modular programming. The pipe symbol (|) sends the output from one command as input to the next. For example:
grep "@param" Decode.java | sort
combines the grep and sort commands to compile a sorted list of
@param javadoc comments.
The pipeline is simple but effective. It works for developers who concentrate on writing atomic commands (over the years, they have built a sizeable collection). It works for users who combine simple commands into sophisticated processes.
Yet, because it relies on text streams, the pipeline is not appropriate for complex datasets. Until XML, that is. Developers are rediscovering the benefits of writing tools that concentrate on one task and work best when combined with other tools in a sort of modern pipeline.
Delta XML, a product from Monsell Ltd., in the U.K., is a prime example of that trend. I recently sat with Robin La Fontaine to find out more about this product.
Monsell was originally a consultancy that specialized in identifying changes in the design of circuit boards. In 1998, they decided to apply their expertise to XML and the result is Delta XML.
|What impressed me most with Delta XML is that it does not try to be all things to all people.|
You are probably familiar with the diff command (or Windiff) which you may have used to spot updates in code. Delta XML performs a similar role for XML documents. Unlike diff, however, it knows about the syntax and does a tree-by-tree comparison instead of a line-by-line one.
“One application is regression testing where the developer compares the output of different versions of the application,” explains La Fontaine.
A more interesting application is version control. “Delta XML can not only compare files but also reconstruct them from the delta,” adds La Fontaine. “Suppose you compare two files: A and B. The delta is recorded in a third file, C. Applying C to A generates B, applying C to B recovers A.”
This feature also offers an XML rollback. If you need to rollback to an older version of a document, it suffices to apply the deltas in reverse order. “For example, Delta XML is used to implement the undo function in an XML editor” says La Fontaine.
What impressed me most with Delta XML is that it does not try to be all things to all people. It does one thing well and is designed to integrate with other tools. Specifically, the delta file is an XML document and most users post-process it with XSLT or SAX. According to La Fontaine, “This is particularly easy because the delta mirrors the original document, so you don’t have to modify your style sheet or your application much.”
I encourage you to have a look at Delta XML, not only because it’s a fine tool but also because it is a good example of a refreshing trend: create simple tools and combine them in a pipeline. The Web site is www.deltaxml.com and it offers an online demo.
About the Author
Benoît Marchal is a Belgian developer and writer. He is the author of XML by Example (two editions), Applied XML Solutions, as well as a columnist for developerWorks. Details on his latest projects can be found at marchal.com.