Saturday, April 22, 2006

Structure and Flow - an example in XML editing

Carrying on with the balance of structure and flow, although I left formal methods research a long time ago, I still come across it as a recurring theme in IT work.

At my present workplace, as a software developer I found myself with the task of extending a web-based system to allow anyone to use the web to edit some data encoded in XML. XML (short for 'eXtensible Markup Language) is a hot topic that promises the recording of meaningful information, its long term preservation and wonderful exchange and interoperability among software systems (e.g., because it's stored in a text file, so you can read an XML file in Notepad). An XML file is a data file, basically a hierarchical structure of tags and content. It's structure and data in one.

So where's the flow? That comes in the editing, because to edit the documents I devised a system that used a functional programming language called XSLT [well, it looks like it should be functional, though proof "by example" doesn't look like proof!]. Every change to an XML document is carried out in terms of XSLT, i.e. suppose we have XMLDOC1, then apply an XSLT stylesheet xslt1 to get XMLDOC2; and then apply xslt2 to get to XMLDOC2 and so on. In practice, each stylesheet defines a slight change in the document, with all else remaining the same. The operative verbs are simply: add, delete, and update. Perhaps you could use the word 'perturbation' for this?

As it happens, an XSLT stylesheet is actually an XML document, so again it has all those nice qualities described above, which means that using this system not only allows you to have a convenient text-based history of the documents, but also of the transformations and I can not only share data, but the transformations needed to carry out changes. There's a walkthrough illustrating what I mean through a number of screenshots.

Now there's an irony in using XSLT for change because as instances are XML documents it means that the transformations are themselves data and structure. So in one sense we have a sequence of data structures - where data and the way it changes is in the same format. But what I haven't addressed is how you actually generate and carry out the transformations. This requires a processor!

I've grown to appreciate this system for it gives me a sense of holism - a stream of documents and transformations in one flow. It certainly intrigued one of my colleagues, for whom XML and XSLT are very much his bread and butter!

No comments: