| |
Getting practical
![[d31adbf6.gif]](d31adbf6.gif)
So, how is XML commonly used? In the diagram below, you can see how your existing solutions – in this case a browser and a database (and presumably ASP as the glue) can be enhanced with XML. The most common situation is shown below, in which this solution will be used this is if you wanted to transform your data on the client side (in the IE5 browser).
In other words, if you need to send data to the clients without already having specified how the data will look until it gets there, this is your likely scenario: Another example of using XML is shown in the graphic below:
Note how the transformation is done on the server side and the results (usually HTML) are sent to the client. This is useful because the output can be precisely controlled base on the calling application. For example there has been an increase in WAP (Wireless Application Protocol) applications surfing the web and these websites are unavailable to the existing browsers.
For an example of this, visit http://www.wapaw.com which is a website intended for WAP browsers.
Using the system described above, each visitor could be provided with a custom view based on the visitor’s requirements. In other words, when my IE5 visits their website, this kind of website won’t send me away empty handed with only a “we only server XYZ browsers” message.
Sure you could use browsercap.ini to identify the browsers visiting your website, but you would still have to do a fair amount of work in order to prepare different versions of your website for each browser.
XSL can be used to render these different websites and pages automatically. Now, the same data (the XML document) can be transformed into many different outputs for the different browsers or even for much more interesting uses, which we’ll cover a bit later!
Below in the graphic, you can see how XML combined with XSL can produce the desired output. So, with a single XML data and with many different XSL stylesheets, you can produce many different outputs!
This concept is not new, as the HTML developers out there will know. CSS (Cascading Stylesheet) provided a similar function for HTML pages, but XSL is better… much better as you’ll discover.
You see, all XML documents can be manipulated programmatically using the DOM (Document Object Model). The DOM (which ships with IE5) is a great way to tweak and manipulate XML documents and this saves you having to manipulate strings in the XML text files. The key thing about the DOM is that you can use it from within your development environments, such as Visual Interdev or Visual Basic.
So what’s so great about XSL then? Since it is also a text file built from XML, so it can also be created, extended and manipulated by using the DOM from your programs!
How would that work and why is it useful? OK, let’s imagine you have a database with some really useful data in it and your clients will be asking for that data to be provided in all kinds of formats.
Many programmers know what it’s like to maintain many different versions of the same application because of different client needs. In some cases, this is a great reason not to use Visual Basic but to move to HTML where it is easier to create and maintain user interfaces or to dynamically apply them. You could prepare many copies of HTML pages for each format which the clients ask for. The downside of this is in HTML it is difficult to separate the data from the design,. In XML, the separation is very clear. XML is the data, XSL is the design and manipulation of that data. In this alternative, you can prepare one XML file and several XSL files where each XSL file will transform the XML file into the different data formats the clients are be looking for! This is great, because clients with low bandwidth have needs which are very different to clients with high bandwidth needs. In the future, what kind of layout would
you need for a hand held or wireless browser? And lastly, it could be even more exciting… the different XSL stylesheets could only display content based on what the user needs or based on the context! Now let’s take a look at the business implications of XML and the impressive growth of the Internet.
|
|