Minimal IT logo and link to home page
Research, training, consultancy and software to reduce IT costs
Home | About | Newsletter | Contact
Previous | Next Printer friendly
29 June 2010

XML-based programming 5: building blocks

By Andrew Clifford

XML-based programming makes building complex new functionality from simple building blocks as easy as manipulating XML data.

Using XML as the basis for programming means that you can easily represent service requests and responses as data. You can use XML techniques, particularly XML transformation using XSLT, to create service requests, modify service results, or even to implement services. XSLT allows you to use low-level services as building blocks for higher-level services, or to build new programming interfaces on top of existing services.

As an example, our Metrici Advisor application has a fairly abstract internal data structure. We have XML-based services to retrieve portions of this, which we use to build parts of the user interface. The structures are a bit too abstract to be a useful starting point for reporting, so we use an XSLT stylesheet to convert the output to a more meaningful reporting structure. We can therefore have a single extract service that serves two purposes: building the user interface, and providing meaningful data for reporting.

Multiple services can be combined into one service using a simple "RunAll" service that processes a request that is itself a list of requests for other services. This is very powerful when used with XSLT. For example, we use this to convert a simple specification of a demonstration account into a series of service calls and database loads required to configure the demonstration.

It is easy to build intelligence into the execution of multiple services. For example, in our test harness, we have a simple "Switch" service that runs one service and, based on an error code, runs one of two other services. This allows us to build more complicated XML-based test harnesses that, for example, raise errors when compares fail.

XSLT extensions make it possible to call XML-based services directly from XSLT. You can use XSLT to build the request and interpret the results, just using the extensions to invoke the service.

We have had mixed results with this method. It works fine for small, non-intensive requirements. However, our attempts to run thousands of service invocations from XSLT have been unsuccessful, largely because of memory management problems.

These experiences have shown us that using XML gives a lot of flexibility for adding functionality on top of existing functionality, by combining services together, or by modifying the inputs and outputs. You can, of course, do this in other languages, but XML makes it easy because the tools you use to build high-level services are the same tools that you use to manipulate data.

We have also learnt that these capabilities have to be used carefully. XML-based tools are good for transforming data, which could be service inputs and outputs. However, they are not necessarily good execution environments, and do not have the performance, memory management and error handling that you would have in a programming language such as Java. But mixing both, using XML technologies for transformation, and conventional programming languages for execution, gives us a very flexible environment for developing complex new functionality on top of simpler building blocks.

Next: XML-based programming 6: the dark side

Subscription

Subscribe to RSS feed

Latest newsletter:
Magical metadata

We use the term "metadata-driven" to describe IT solutions in which functionality is defined in data. Taking this to the extreme can provide unparalleled levels of speed, simplicity and versatility.
Read full newsletter

System governance

System governance helps you implement high-quality systems, manage existing systems proactively, and improve failing systems.

Find out more