Datasheet
A fair amount of Ajax code will deal with handling cross-browser code and handling errors if and when
they arise, unless you can guarantee that your target audience will only ever use one browser (such as
on a local intranet). This is an unfortunate set of circumstances that even new versions of IE and Firefox
are not able to rectify. Later chapters address both of these dilemmas.
XML, XSLT, and XPath
XML is another familiar cornerstone, the language that is used to describe and structure data, to any web
developer.
With XML comes a whole plethora of supporting technologies, each allocated its own individual niche.
An XML document contains no information about how it should be displayed or searched. Once the
data is rendered as an XML document, you typically need other technologies to search and display infor-
mation from it. IE and Firefox both contain XML engines that can parse XML documents.
XSLT is a language for transforming XML documents into other XML documents. It isn’t restricted to
transforming XML documents into XML. You could also specify HTML or pure text as the output for-
mat. When you transform a document, you start with a source XML document, such as the following
fragment:
<HotelList>
<Hotel>
<Name>Hotel Shakespeare</Name>
<Rooms>50</Rooms>
<City>Birmingham</City>
</Hotel>
<Hotel>
<Name>Hotel Washington</Name>
<Rooms>500</Rooms>
<City>Chicago</City>
</Hotel>
</HotelList>
You apply a second document in XSLT to the first document. The XSLT document contains a set of rules
for how the transformation should be conducted, as shown here:
<xsl:stylesheet version=”1.0”
xmlns:xsl=”http://www.w3.org/1999/XSL/Transform”>
<xsl:template match=”/”>
<table>
<tr>
<td>
Hotel Name
</td>
<td>
Number of Rooms
</td>
<td>
Location
</td>
</tr>
<xsl:for-each select=”//Hotel”>
12
Chapter 1: Introducing Ajax
04_106754 ch01.qxp 2/9/07 6:15 PM Page 12