Categories
XSL

XSL Cookbook

Extensible Style Sheets are for XML, what Cascading Style Sheets are for HTML. XML content.

The transformation process is the automated process of copying the information from the source XML document, processing it (e.g., running calculations on it, sorting it, filtering it, etc.), writing the processed information into a new document of a particular presentation type (XML, HTML, XHTML, PDF, CHM, etc), and then applying custom rendering to it (format styling).

Background

Unlike HTML content, is ambiguous outside of the content of it’s schema (namespace). Therefore, Extensible Style Sheets are written in a language that allows the XML content to be described generically, and redefined (transformed).

If you think of the process of applying style sheets to HTML content as passive, then it makes sense to view the process of applying style sheets to XML content as active. Since you can do so much more with an XML file than simply style it, the name Extensible Style Sheet is misleading.

The terms are confusing

XSL used to refer to the programming language used to program Extensible Style Sheets. Now, the term XSLT is used instead. It stands for “Extensible Stylesheet Language Transformation”. “xsl” is the file extension for Extensible Style Sheets, and it is also used as the XSLT namespace.

The term “Transformation” is misleading. The transformation process doesn’t actually transform XML content (it doesn’t alter the source file).

XSL now refers to a family of three languages

And they all play a part in the transformation process: XSLT, XSL-FO, and XPath.

XSLT – the language for transforming source XML content.

XSL-FO – the language for formatting output content.

XPath – the language for navigating source XML content. XSLT uses XPath to define RegEx-like expressions to match parts of the source XML document. XSLT defines one or more transformation templates, for processing matches; each one with a different XPath match definition.

Rendering in a Web Browser

After you create an XSL style sheet for a particular XML file, you can put the XML file up on the web, and it will render according to the style sheet if you embed a reference to the style sheet, within the XML file. This is because modern web browsers can process XSL Transforms (just like Saxon).

Leave a Reply