XML technologies / XSLT / XSLT Cookbook / Transforming XML into HTML

(Excerpt from “XSLT Kochbuch” by Sal Mangano)

“I was surprised that people were willing to enter cumbersome HTML without complaint.”
Tim Berners-Lee

Introduction

If I had to estimate, I would say at least 60 percent of HTML transmitted over the Internet today is at least partly generated by code. This is not because writing HTML is cumbersome, as Tim Berners-Lee suggests in the opening quotation, although it is and we now have fancy editors. Rather, dynamically generated HTML offers far more possibilities.

Many open and proprietary technologies create HTML content from data stored in other forms. When that data is XML, XSLT is one of the most important tools every web author should know.

There are three basic ways to generate HTML with XSLT.

First, transform XML into HTML and store the result statically on a web server or disk for delivery to a browser. This is also useful for testing transformations.

Second, use XSLT for server-side scripting: the server dynamically transforms XML from raw files or databases when a browser requests it. This suits frequently changing data. A combined approach generates HTML on demand but caches it until the underlying data changes, reducing repeated transformations. For server-side XSLT, look at Apache Cocoon.

Third, use XSLT as a client-side stylesheet, if the browser supports it. At present, Microsoft Internet Explorer 6.0 or later, Netscape Navigator 6.1 or later, Mozilla, Firefox and Apple Macintosh Safari (Tiger) have built-in support. Older IE versions require MSXML 3.0 installed in replace mode. In addition, XSmiles and Antenna House XSL Formatter provide client-side XSLT processing and display the result. XSmiles handles many result types, including SVG and XSL-FO, though its HTML support is imperfect. Antenna House XSL Formatter also handles XSL-FO. Since this area changes rapidly, consult current online documentation for your browser or extension.

  

  

 

 

 

back to top