Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


XHTML: HTML Merges With XML  : Page 3

The W3C's recently approved XHTML standard combines HTML and XML and makes it possible for your Web pages to be viewed on a wider variety of devices.


While the rules for using XHTML are simple, in some (perhaps most) cases, this simple change can play havoc on archived HTML material. What benefits does anyone derive by using XHTML over traditional HTML? To really appreciate the benefits of XHTML, it's worth understanding a little bit about the true value of XML in the first place. XML isn't HTML with custom tags—even though that was one of the primary rationales for creating XML in the first place. XML is a language for representing complex relationships between objects (hearkening to the object model discussed previously). Moreover, one of the principle technologies at work with XML is the Extensible Stylesheet Language (XSL).

If you are familiar with Cascading Style Sheets, you may think that an XSL style sheet is simply a different way of expressing styles. It isn't. XSL is a technology written in XML that can associate given element patterns in an XML document with other collections of strings (or better yet, with elements from a different XML form). XSL can take an XML document as input and convert it into HTML, for example. However, if that HTML document isn't also an XML document, then most XSL parsers have to manipulate the HTML as strings, which is much less efficient than manipulating the element as internal binary objects.

Moreover, XSL can't transform HTML into XML unless the HTML is also well-formed XML. On the other hand, with XHTML you can perform a direct transformation into another XML structure (or even into different XHTML), pass an XHTML document through but change only a few selected elements, or retrieve information that may be contained in an HTML table and convert it into a different XML structure.

For example, you could create a relatively simple XSL transform that would read through an XHTML document and convert any expressions of the form <clock:showTime format="long"/> into the expression <span class= "clock">3:25:16 PM PST</span> when displayed. This gives you the capability of creating a tag-based system of output similar to Allaire's Cold Fusion, but one in which you could explicitly define all of the actions that you wanted to perform.

Similarly, you could store XHTML blocks within an XML document or server that could then be easily retrieved through the use of another XML technology—XPath. XPath gives you a way to perform fairly complex queries on the nodes and extract data at any level of complexity. Most traditional index servers use a brute force method to index a site—recording the positions of given words in their respective files. The results of such searches are thus only as current as the last time the site was indexed, and moreover prove problematic when dealing with dynamically generated data.

With XHTML, on the other hand, the information can be retrieved much more topically—if you know the best structure of the documents at hand, you could specifically retrieve only those sections within documents that pertain to the current record. For example, you could retrieve only the tables in a document, or only Table 3 in the document, or only tables that contained Northwest sales amounts for Fall 1999 in excess of $20,000,000 dollars. This level of specificity compares favorably to that of SQL, without any of the headaches of dealing with JOINs and trying to reconstruct hierarchical data.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date