Transformations

A couple of months ago I wrote some XSLT stylesheets to extract information from W3 Schemas, and generate documentation from them in HTML format. I can't say I didn't have fun, because I did (I'm easy to amuse sometimes), but as always when I am working with XSLT, I wished I had a better way to do XML transformations.

XSLT is a powerful transformation language, but it is also very verbose, and the XML compliant syntax is definitely not designed for editing with a text editor. Also, you often need to write an application in some other language to get a complete application. Transformations are usually only a part of the job.

I had just become interested in Ruby, and also came into contact with Rake, a make-like (Ant-like, for Java programmers) build utility. Rake is written entirely in ruby, and has a very nice declarative syntax.

While I was immersed in Ruby/Rake, some of my XML neurons suddenly fired up. If Ruby is good for writing a declarative build language, maybe it is good for writing a declarative transformation language?

After a bit of fiddling, I had a working prototype of a very small DSL (Domain Specific Language) for making declarative XML transformations. I promptly named it Declan (Declarative Language), for want of better ideas. (I did have some worse ideas, but I won't discuss those.)

I also had a problem: writing an XML transformation language would obviously require a lot of unit testing. An excellent unit test framework, Test::Unit, is part of Ruby's standard library. There is no support for testing XML though. Nor was there any such framework available on the Web.

I briefly considered using XMLUnit, a Java test framework instead, but that would require me to mix Ruby and Java code in the same project. It felt cludgy, to say the least. Better to do things properly, and write a Ruby framework for testing XML. I realized that I wouldn't have to do it from the ground up. Test::Unit is well written, and quite easy to extend.

Said and done! Test::Unit::XML was born. Test::Unit::XML mixes in assertions for testing XML documents in the Test::Unit::TestCase class. I feel like a proud father today, because I have made the first code release on RubyForge.

The plan right now is to focus on Declan, and let the needs of Declan drive the development of Test::Unit::XML.

The funny thing is that as soon as I begun working on Test::Unit::XML, I realized that it is by far the most useful of the two projects. Every XML project needs an XML testing framework. The challenge now is to make Test::Unit::XML so good that Ruby programmers will want to use it.

Watch this blog for more about both the projects.

Comments

Popular posts from this blog

Waterfall - The Dark Age of Software Development Has Returned!

Waterfall vs. Agile: Battle of the Dunces or A Race to the Bottom?

Interlude: The Cost of Agile