Article
Get XSL To Do Your Dirty Work
XSL: The 2 Minute Tour
Extensible Stylesheet Language, or XSL for short, is a combination of three individual languages, all of which are endorsed by the World Wide Web Consortium (W3C):
- XSL Transformations (XSLT) let you define a set of rules that take an XML document, carve it up, and spit out a document in another format. XSLT 1.0 was officially released in November 1999, and newer versions are under development.
- XML Path Language (XPath) lets you point to tags, attributes, and other things inside of an XML document with paths similar to the file and directory names your computer uses to access files on your hard drive. XSLT uses XPath to pick out sections of an XML document to be used in the conversion to another document type. XPath 1.0 was standardized in November 1999 at the same time as XSLT, and has remained stable since then.
- XSL Formatting Objects (XSL-FO) comprise the portion of the XSL standard that let you format sections of a document created with XSLT by specifying attributes such as colors, font, and spacing when the document type that is to be created supports them (e.g. PDF). XSL-FO was only finalized on October 15th 2001, an event that heralded the official release of the complete XSL 1.0 specification.
Confusing combinations of standards aside, XSL is a much more robust, and (despite appearances) much less complex way of processing custom-tagged documents for display as formatted HTML pages.
Fig. 2: XML to Formatted HTML Conversion with XSLAs shown in Fig. 2, you just feed an XML document along with the XSL stylesheet that contains the rules to convert it to HTML into an XSL processor (there are quite a few available). The XSL processor handles all the checking for missing or invalid tags and then performs the transformations specified in the XSL stylesheet. What's produced is your fully formatted HTML document, ready to be sent to the user's browser!
Microsoft Internet Explorer 6+ and Netscape 6+ both have standards-compliant XSLT processors built in (that is, they support XSL Transformations, but not the newly-introduced XSL-FO portion of the XSL standard), which makes it really easy to learn XSL on your own computer before you put it to work on your site. Let's look at an example to demonstrate the basics of XSL.