The Extensible Stylesheet Language (XSL) is one of the most intricate parts of the XML specification. It’s also a bit of a moving target right now: as we write this, the XSL specification is moving in a completely new direction, possibly becoming its own language in the future. Much of the information in the following pages will be out-of-date very soon, as it is based on the current XSL specification in early 1999. For the very latest information on XSL, visit the home page for the W3C XSL working group at http://www.w3.org/Style/XSL/. This section will still provide you with a firm understanding of how XSL is meant to be used.
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/1.gif"/> <OReilly:HeadA>Starting XML</OReilly:HeadA> <OReilly:Body>If you haven\(ast 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 haven\(ast used XML, then ...</P> ...