The Extensible Stylesheet Language

The Extensible Stylesheet Language (XSL) is one of the most intricate parts of the XML specification. As of this printing, the XSL specification itself is undergoing many revisions; the information presented here comes from the XSL specification dated 16 December 1998, which is classified as a “work in progress.” A final W3C recommendation is expected from the XSL working group by August 1999. If you wish to obtain more recent information on the standard, we encourage you to visit the W3C XSL working group home page at http://www.w3.org/Style/XSL/.

As we mentioned, XSL works by applying element-formatting rules that you define to 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/xmlch1.gif"/>
    <OReilly:HeadA>Starting XML</OReilly:HeadA>
    <OReilly:Body>If you haven't used XML, then you're in...
      </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/xmlch1.gif"/>
    <H2>Starting XML</H2>
    <P>If you haven't used XML, then you're in...</P>
  </BODY>
</HTML>

If you look carefully, you can see a predefined ...

Get Webmaster in a Nutshell, Second 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.