Optimized Presentation of XML Content
- Introduction
- The Framework
- The Solution
- Browser Checking
- Static XML Files
- Summary
Introduction
The internal representation of static web site content or dynamic data displayed on a web site is increasingly stored in XML format due to ever-widening support of XML in scripting languages, web browsers, and SQL databases. Before this semantically structured data is presented to the end user, it’s almost always transformed into browser-friendly HTML markup.
There are many ways to perform XML-to-HTML transformation. Sometimes programmers use XML Document Object Model (DOM) calls in web server scripts to extract individual fields and attributes from the XML data and insert them into an HTML template. Similarly, some AJAX solutions download XML data to the browser and perform the copy/paste operations there. More advanced engineers usually tap the power of XSLT to handle XML-to-HTML transformations on the web server or within JavaScript code on browsers supporting XSLT.
All of these solutions are suboptimal for the following reasons:
- If you perform XML-to-HTML conversion on the web server, you’re wasting server CPU cycles and increasing the page download time. (HTML output is almost always significantly larger than the corresponding XML data.)
- If you perform the conversion on the web browser within an AJAX framework, the web pages are not visible to search engines, older browsers, or users who have disabled JavaScript.
In the following sections, you’ll learn how you can use the XSLT technology to reduce the document download time and server CPU utilizations for most of your visitors, while at the same time retaining compatibility with older browsers and ensuring visibility to search engines.