An introduction to XML

This page was written in 1999.

XML (eXtended Markup Language) is a relatively new subset of SGML (Standard Generalized Markup Language). Its purpose is to give a general grid in which people can define a markup language for their own requirements.

Here is a simple example of an XML file: an entry in a product database:

	<name>Flying Suit</name>
	<price>Euro 1333.=</price>
	<description>Using our Interactive Flying Suit, you can
		now fly over 6 kilometers at an
		altitude of 2 km!</description>

This is all very clear. In simple cases like this even people who have only little knowledge of computers will be able to make a slight change in the data. Changing, say, a product number is not a very complicated task.

However, XML is only a method of structuring data. The example above tells us that a certain product has a certain name, product number and price, but it does not tell us (or a computer) what to do with this information.

So we need interfaces, both to humans and to computers. To make an interface, it is necessary that we somehow open the XML file, read its content and then do something with them, write them into a database or to a browser. We can do this with almost any language: Perl, ASP, PHP, XSL, JavaScript etc. Using such a program we can present the product database in a user-friendly way.

Server Side XML

Before continuing it is important to distinguish between server side and client side XML. The main difference between these two is where the XML is "read": where the program resides that reads the XML file and writes the output. Perl, ASP and PHP are all server side languages, while XSL and JavaScript are client side languages.

So let us suppose we have a Perl program and a website with a link "XML Product Database". When the user clicks the link, the Perl program starts up and reads out the XML file. It then throws away the XML tags (<product> and so on) and rearranges the data a bit to produce HTML, which is sent to the browser of the user. For instance:

Name Number Price Description
Flying Suit 19883-F.3B Euro 1333.= Using our Interactive Flying Suit, you can now fly over 6 kilometers at an altitude of 2 km!

It is important to remember that the user receives an HTML page with, among other things, the table above. He does not receive the XML file itself.

So with server side XML the XML is interpreted by the server, who sends the resultant data (usually an HTML page) to the clients (the browsers of the users).

Client Side XML

Now let's suppose the same XML file and the same link "XML Products Database". What happens with a client side solution?

When the user clicks the link, the entire XML file is sent to the browser. The first problem is there: the browser must recognize that this file is in fact XML. The only two browsers that can currently do this are Internet Explorer 5 and the experimental Gecko browser that will form the core of Netscape 5.

Having loaded the XML file it's now up to the browser to present the data. In practice there are two possible languages: JavaScript and XSL. Although the XML example that I made uses XSL, I have come to the conclusion that for the present JavaScript would be the better choice.

XSL (eXtended Stylesheet Language) is a language specially designed for presenting XML data. This sounds very good, except for two things:

  1. It is only implemented in Explorer 5, not in Netscape 5.
  2. The Explorer 5 implementation has a few problems which are described on the About the XML/XSL example page.

Because of these two problems JavaScript currently seems to be the best choice for client side XML. If we decide to use client side XML for the Job Description File, we will use JavaScript to display the information.