display | more...

XML is a latest buzzword on the Internet and the Web. Crowned as the future mark-up grammar for information exchange, XML is already being put to use in an astonishing number of applications.

XML's goal is to provide a universal mark-up grammar to define the meaning of data, with a view of using it to replace HTML on the web with a more meaningful and data orientated mark-up (often synonymous with the semantic web or the information web). However XML is still in it's infancy when it comes to server/client interaction via an HTTP server and a web browser, the XML specifications and client browsers are not mature enough for the daily use of XML for web pages. However, there are ways we can use XML on the web today to improve the way we write web applications, by using XML and XSLT to provide an abstraction layer between form and function.

With a server side scripting engine (like PHP, Perl or ASP), an XML parser (like Expat, libxml or MSXML), and an XSLT processor (like Sablotron or MSXSL), you can use XSLT to define your form and XML as an output of your function.

It works something like this. When a HTTP request comes to your HTTP server for a certain piece of information, the scripting engine is invoked which fetches the required information from your database. The information is then used to generate an XML document in memory, which in turn is passed through the XSLT processor and transformed into HTML via the format definition in the XSL stylesheet. This HTML is then sent to the client as an HTTP response.

By using this approach, the functionality of the web application generates a standard XML document (the definition of you define previously) holding pure information, and the presentation of this information is stored separately and applied to the information just before sending it to the client.

The advantages of this technique are numerous, but include:

The disadvantages are of course the overhead of doing the XSL translation, however this is probably very small when compared to database access and script processing time (of course it depends on the speed and efficiency of the XSLT processor).

I have implemented the above web application architecture using both PHP/Sablotron and ASP/MSXSL and have been very impressed with how easy the extraction of form and function is to achieve and work with. I'd recommend this technique to anyone starting a complex web application where separating form and function is important, or to anyone wanting to learn more about XML and XSLT.

Log in or register to write something here or to contact authors.