| Reuse and Reality: A Journey from Ideal Concept to Real World Implementation | Table of contents | Indexes | The gorge between the X-volution and the real world | |||
A Travel-Related Case Study Using XML |
| Paul Spencer |
| Managing Consultant |
| Boynings Consulting
East Boynings 29 Altwood Road Maidenhead Berkshire SL6 4PB United Kingdom Phone: +44 (0)1628 687010 Fax: +44 (0)1628 687011 Email: paul.spencer@boynings.co.uk Web: http://www.boynings.co.uk |
Biographical notice: |
Paul is the author of "XML Design and Implementation" |
ABSTRACT: |
The application also uses XML to provide a common language for transmitting data between systems, using a DTD to provide a level of error checking. |
IE5 ![]() Internet Explorer 5 ![]() Wrox Press XML ![]() case study ![]() |
In this paper, I will discuss the use of XML in an application I have called Centaur. This was developed as a demonstration of XML in Internet Explorer 5 and as a case study for a book on implementing systems using XML . The application itself can be accessed (using Internet Explorer 5) on the Wrox Press web site athttp:// webdev.wrox.co.uk/books/2289 . |
Centaur ![]() |
My aim here is not to discuss the application itself, but a brief overview is useful. Centaur forms the middle tier in an environment for booking inclusive tours. By inclusive tours, I mean vacations supplied as complete entities by a single company that bulk books airline seats and accommodation, provides ground transfers between the resort airport and the holiday destination and provides representatives at the resort. In the UK, these are known as package holidays, and are usually booked either directly or through travel agents from descriptions in brochures. |
|
||||||
electronic brochure search ![]() |
In operation, the tour operators submit brochure-type information to the system, which stores this and allows searching based on several criteria. The user can then see descriptions of the tours and select some to store in an electronic brochure, which can be browsed off-line. It would be simple to allow this brochure to be written to a CD-ROM. Once a tour has been chosen, the client fills in a form to request a quotation. This information is sent to the tour operator system, and the reply is rendered to the browser. A similar mechanism is used for booking. |
XML ![]() |
Centaur comprises two main parts - a search system and a booking system. A fully functional system would have a third part to collect data from the tour operators. XML is used on both the client and the server, to a degree that would not be possible in a commercial system because of the need for browser independence. |
XML ![]() database ![]() query |
Once the user enters the system, she is presented with a search screen, in which she can enter some requirements for the vacation. This is done in a normal HTML form and results in a search of the local SQL Server database. This is entirely conventional. The database query reports its results as a simple piece of XML such as: |
<results> <result> <tourid>6</tourid> <tourOp>Argo</tourOp> <name>Hotel Miramare</name> <area>Cyprus</area> </result> <result> <tourid>5</tourid> <tourOp>Argo</tourOp> <name>Hotel Mediterranean Beach</name> <area>Cyprus</area> </result> </results> |
DOM, Document Object Model ![]() HTML, Hypertext Markup Language ![]() JScript ![]() XML ![]() database ![]() |
This XML is then manipulated in JScript with the DOM to provide, as HTML , a list of matching tours, any of which can be clicked on the display details of the tour. Traditionally, this would have been done by combining the database extraction and the formatting code. By providing the intermediate XML , we make it simple to modify the screen appearance without modifying the more complex code. In this case, this is of marginal benefit. Once we start to look at the details of the tour, it is of much more value. |
Clicking on a tour from the list brings up brochure-style information: |
|
||||||
HTML, Hypertext Markup Language ![]() XML ![]() database ![]() |
As the vertical scroll bar in the diagram shows, there is a lot more description to follow, including a price table. This information is extracted on demand from the database, and formatted as XML . The XML is then rendered using an XSL stylesheet. This has many benefits over combining the database extraction and rendering in a single stage with HTML . |
XML ![]() database ![]() look and feel parallel development |
The first is parallel development. Knowing the data I needed, I could specify the XML file structure for someone to develop the five hundred lines of database extraction code. While he was doing this, I could get on and separately develop the look and feel of the page. This separation of tasks is very common, and in the past has led to developers providing a basic look and feel, then graphic designers getting the appearance how they want separately. Since the graphic designers have to work with complex code, this often leads to errors. The total separation of the tasks with XML as an intermediate format not only allows parallel working, but eliminates these errors. |
maintainability ![]() |
Closely related to this is maintainability. If I want to change the appearance of the page (and I did so several times while developing the system), I just change a stylesheet. The complex database code is not touched. |
XML ![]() XSL ![]() style ![]() stylesheet ![]() |
I can also add variety. I could, as the operator of this system, develop different stylesheets for different tour operators. I could even charge for developing a more vibrant style than the standard. I could also vary the style according to other parameters. Perhaps I could use the internal reference of the tour to select one of several standard stylesheets to add variety. All this can be done while maintaining only a single version of the database extraction code - something that is dependent on the use of XML as an intermediate format. |
HTML, Hypertext Markup Language ![]() IE5 ![]() Internet Explorer 5 ![]() XSL ![]() |
Since I am using XSL , I am totally dependent on the client being Internet Explorer 5. However, it is trivial to regain client independence by changing the code to do the stylesheet processing on the server and send HTML to the client. The only disadvantage in this case is the additional server load. In other applications there could be further disadvantages since delivering XML to the client allows significant client-side processing. Doing this processing on the server can mean delivering large HTML pages when only small changes are required. |
JScript ![]() XML ![]() cookie ![]() |
Once a tour has been selected, the user can do one of two things. The first is add it to a brochure. She can then select further tours and add these to the brochure as well. The brochure can be saved as a cookie and restored in a later session. This cookie is an XML string simply because it is simpler to manipulate parsed XML than simple strings in JScript. |
DTD, Document Type Definition ![]() HTTP, Hypertext Transfer Protocol ![]() MSXML XML ![]() XMLHTTP schema ![]() |
It is obviously a benefit to have a standard interface here, and so XML is used. The MSXML parser can be run on the server as well as the client, and includes an XMLHTTP component for sending and receiving XML messages over HTTP. Since we are dealing with systems outside our control, it is useful to have automated error checking, and so the messages reference an external DTD. All information is put in attributes rather than text nodes so that the DTD can do more checking. Using a schema rather than the DTD would provide even better checking, but the decision was made at this stage to stick with the fully standardised DTD, rather than the proposals for schemas. |
A typical quotation request would look like: |
<?xml version="1.0"?> <!DOCTYPE centaur SYSTEM "http://www.centaur.co.uk/centaur.dtd"> <centaur> <quoterequest> <qttour supplier="argo" ref="1130" depdate="19990801" duration="14" /> <qttravellers adults="2" children="2" infants="1" /> </quoterequest> </centaur> |
The reply to this might be: |
<?xml version="1.0"?> <!DOCTYPE centaur SYSTEM "http://www.centaur.co.uk/centaur.dtd"> <centaur> <quoteresponse> <qrdetails availability="true" quote="2214" notes=" /> </quoteresponse> </centaur> |
DOM, Document Object Model ![]() HTML, Hypertext Markup Language ![]() JScript ![]() |
This information is then inserted into the resulting HTML page using JScript and the DOM . |
XSL ![]() |
The booking process is similar to this. The messages are more complex, making it more worthwhile to use XSL for the display. Again, this is done on the client, but could equally well be done on the server. |
XML ![]() |
As I mentioned at the beginning, this system was built as a demonstrator and as a case study for a book. A third purpose was to gain experience in a significant XML development at our own expense rather than our clients'. For that reason, it was important to review the project and its use of XML and the lessons we learnt. |
XML ![]() cookie ![]() |
With the experience we already had, we knew XML was an appropriate technology for the project. However, once we started, we found continually that there were places where XML could make things a little easier than they would otherwise have been. An example is in saving the brochure as XML . Although this uses up additional cookie space, it makes processing that little bit easier. This sort of use is very appropriate in intranet (and possibly extranet) environments where there is control over the client. |
XML ![]() relational database ![]() |
The area we would consider doing differently next time is the data storage. We stored all data in a relational database and converted it to XML on the fly each time the data was requested. In fact, much of this data could have been stored in XML . The only parts that need fully relational storage are those that are used for searching. Since the tour operators would be supplying information in XML format, this would save conversions to and from relational formats. |
HTML, Hypertext Markup Language ![]() XML ![]() guidelines |
This project is typical of those that would previously have used only HTML for markup. Building the system has shown us the scale of the benefits XML can bring, whether or not browser independence is an issue, and provided us with guidelines for its use. |
Acknowledgments |
I would like to thank the staff at Wrox Press and the external reviewers who helped with the writing of the book. I would also like to thank Darren Gill, who assisted with the programming of Centaur. |
|
Bibliography |
| Reuse and Reality: A Journey from Ideal Concept to Real World Implementation | Table of contents | Indexes | The gorge between the X-volution and the real world | |||