The Extensible Stylesheet Language

The Extensible Stylesheet Language (XSL) is one of the most intricate specifications in the XML family. XSL can be broken into two parts: XSLT, which is used for transformations, and XSL Formatting Objects (XSL-FO). While XSLT is currently in widespread use, XSL-FO is still maturing; both, however, promise to be useful for any XML developer.

This section will provide you with a firm understanding of how XSL is meant to be used. For the very latest information on XSL, visit the home page for the W3C XSL working group at http://www.w3.org/Style/XSL/.

As we mentioned, XSL works by applying element-formatting rules that you define for each XML document it encounters. In reality, XSL simply transforms each XML document from one series of element types to another. For example, XSL can be used to apply HTML formatting to an XML document, which would transform it from:

<?xml version="1.0"?>
<OReilly:Book title="XML Comments">
 <OReilly:Chapter title="Working with XML">
  <OReilly:Image src="http://www.oreilly.com/1.gif"/>
  <OReilly:HeadA>Starting XML</OReilly:HeadA>
  <OReilly:Body>
    If you havent used XML, then ...
  </OReilly:Body>
 </OReilly:Chapter>
</OReilly:Book>

to the following HTML:

<HTML>
  <HEAD>
   <TITLE>XML Comments</TITLE>
  </HEAD>
  <BODY>
   <H1>Working with XML</H1>
   <img src="http://www.oreilly.com/1.gif"/>
   <H2>Starting XML</H2>
   <P>If you havent used XML, then ...</P>
  </BODY>
</HTML>

If you look carefully, you can see a predefined hierarchy that remains from ...

Get Webmaster in a Nutshell, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.