|Newsletter for e-Business consultants and practitioners||January-February 2000|
For dining you should have a knife on the right and fork on the left, a special fork should be placed behind the plate and when it comes to a spoon… Why? Because otherwise it would be "muavais ton" - which means poor, bad or inappropriate manners, tone, behavior. Here, at hi-tech, we are fortunate enough to be free from the français étiquette because breaking it demonstrated impressive efficiency too many times. However, it's still worth to follow some basic rules of civilized behavior, like, for example, not to talk about something you have no idea about. Looks like at XML table we got a bunch of poorly mannered guys, who forgot about this rule in favor of a sales pitch. So, here we are, and this is a kind of overview on what can be done with XML, and what is, probably, not the best idea (like eating soup with a fork and knife). Of course, there is always more than one opinion, so don't afraid to put a knife on the left, just don't forget to use it as appropriate.
XML is a mark-up language like HTML. Like HTML it is defined by the means of the SGML, which is mark-up language to define other mark-up languages. You can get official XML specifications at the same place where HTML specs are: on the site of W3 group. Originally XML was created because HTML provided insufficient expressive power, and complexity of SGML required too much power to use it. XML allows to define new languages (in fact, XML dialects), which can be suited to serve particular purposes. Moreover, XML per se is not a thing you use, but these home-made dialects is what brings special power to this language. So, which purposes?
Even simplest eBusiness systems require database integration. Static HTML page usually does not represent special value, so many pages are generated on a server "on-fly" based on the back-end data. For a long time basic model was to generate HTML code for dynamic pages and fill this HTML code with data. This was done by CGI programs or their equivalents, like Microsoft ISAPI or Visual Basic ASP modules. These programs accessed databases and produced HTML output, merging data and presentation within their code. Now imagine that you have such system with about 100 such modules/programs, and your database just got additional field that you want to show. How to add it consistently? Or suppose you decided to change all tables layout to make them more readable. Ouch…
Now, how it could be done with XML? You web-programs generate XML output like:
And now add formal description how to convert it into HTML. There is a number of options for that:
We will show an example with CSS here. For CSS and XSL your application server probably can make conversion on the server side. If not, you can get off-shelf product and use it with your application server. The important thing is you don't have to code, unless you want to. So let make a simple stylesheet like:
Now, if you have Internet Explorer 5+ you can try to see how it looks like. The XML example should appear this way:
XSL allows even better processing of XML data, inclusion of HTML tags, sorting data and so on. But whatever way is used the key is the same, to change the style you should change it in a single point. Data are separate from the presentation. Change of data has a minimal effect on the presentation layer, and change of look does not affect data.
The technique for this is close to described in previous section, but it gives more. Suppose you want a single look all across your web-site. How it can be achieved?
The evident answer is to use templates. Suppose, your pages look like:
And through standard application and description in XSL, or through your own application, you can replace elements like <header>, <main-column>, <top-advertising> with appropriate HTML code.
Important thing is that you have centralized control over standard elements. For example element <side-ad> may control the advertising code placed on the side column. Now when you get a new advertiser or you lose some advertiser, you just update your database and all pages start to show ads correctly. If you ever built a site with a number of ads, you can understand the value of such improvement.
If you deal with EAI (Enterprise Application Integration) or even just have a need to integrate two applications, there is always a lot of ways to do that. But the important thing is that you don't want too tight connection. Applications tend change and if your connectors are not flexible enough, you will have to change them each time the applications are changed.
For example, suppose you want to integrate HR file with your web, to show public data about your staff. HR system with your connector will give the XML file, like the one used above. Your web system will automatically convert it to HTML and show. Now suppose that your connector from HR system (because of upgrade) started to give up Social Security Numbers, which are apparently not for publication. If conversion is described correctly, your web even will not notice that the new field appeared, it will just ignore it. That's a big difference to most other ways to integrate applications, which could require change to the code and testing.
Caveats include potential performance problems. If you pass several megabytes at a time over fast LAN, conversion may add a noticeable toll to the time of a single call. Another problem may appear if you send XML to the client, to be converted to HTML in the browser. In this case you still have to take care of sensitive data, even though users don't see them directly. However such change is still easy than in a case of a hard integration.
Close to previous advantage is ability to send data across networks with acceptable level of tolerance to change on both ends. If you use XML, any extra fields are just ignored, and missed data may be defaulted, therefore allowing enough time to implement change, or even just ignore the change. Basically this is also integration, which just happens over network.
This is probably not the #1 use of XML, however it also has its' place. Of course, you would not want to place terabyte database in such format, it's too expensive both in terms of a disk space and performance. However personal library of CD records or books on your computer can be easily stored in XML format. Advantages include (but not limited to):
It is likely that with a time, when XSL standard will become more stable, and more browsers will support XML/XSL, this will become very interesting. In fact even now XML can be used in business-to-business applications when developers can dictate which browser to use to access their system. It's another matter that any additional restriction adds work for the support and help desk. And unstable standard may make it even more worse. For example, can we be sure that new version of IE or JVM (Java Virtual Machine) will not affect this functionality? And how to control that?
At the same time we know a company where this approach was successfully used. On the other hand alternative was there own fat client, which can create even more trouble than more or less standard browser can do. So, we cannot advise for or against such approach, we just list cons and pros, and you have to decide for yourself. One thing is for certain, XML in browser currently is not acceptable solution for public Internet sites.
Four most important sources on XML are listed here. And they does not have the hipe, mentioned in the beginning of this paper, these guys really know what they do.
Here are few of XML books, if you need more just search for "XML" on Amazon.com, Borders or Barnes&Noble.