by Stephen Bau

You are reading

XSL Transformations (XSLT) is a markup language for transforming XML into other forms of output, such as XML documents, HTML and many other text-based formats. The World Wide Web Consortium maintains the XSLT standard.

Background

XSLT is the keystone in a trio of languages developed to transform and format XML. Collectively, those languages are known as XSL, or Extensible Stylesheet Language.
Each member of the XSL family has a specific role:

XSLT, or XSL Transformations, is used to transform XML data into other kinds of output.

XPath, or XML Path Language, is used to identify nodes in an XML document for transformation or formatting.

XSL-FO, or XSL Formatting Objects, is a presentational language used for formatting XML data, usually for print.

XSLT as a Standards-Based Templating Language

Though the usage of XSLT as a web templating language is not commonplace, there are a lot of factors that make it ideal for this purpose.

It’s an XML technology. This means native handling of every web feed, every XHTML page, every RDF format, and nearly every API that exists on the web.

It’s an open standard. Maintained by the world’s web standards body (W3C), XSLT is widely-used, widely-supported, and well-documented. You won’t have trouble finding resources or getting answers, and once you’ve learned XSLT it can be helpful anywhere XML is used (which is pretty much everywhere).

It’s content-driven. Everything you output is directly tied to the data you need to present, meaning your presentation can always be lean and semantic.

It’s rule-based. Rules are much more powerful than mixtures of markup and procedural code. They are distinct and self-contained, but can also have complex relationships and interdependencies.

It’s flexible. XSLT can output nearly any text-based format there is, even ones that haven’t been invented yet.

It’s a complete templating language. With XSLT you can craft an organized, coherent presentation system rather than cobbling pages together out of snippets and tags using scripting languages.

XSLT defines sets of instructions that are used to transform source XML and create some kind of output.
A processor starts with some XML content, and as it parses that content, it uses instructions from an XSLT stylesheet to generate some other sort of output.

Many common programming languages are imperative—they issue commands, one after the other. XSLT, on the other hand, is a declarative language. Instead of issuing commands, it simply states what should be done in a given context. It’s rather similar to CSS in that way. Neither language describes a sequence of events or functions. They just say, “When you come across this element, this is how you should style/transform it.”

Templating with this kind of rule-based language takes a different sort of mindset, but it’s actually a much more powerful and flexible approach. A list of commands can only be followed, but rules can have scope and interdependencies, they can cascade, and they can override one another.

Comments for this article

No comments have been made so far.

Comments Closed

Unfortunately, there are those that have decreased the value of offering a comment form on this website by abusing the privilege, so comments have been closed on this site. If you would like to engage in some thoughtful discourse, you can find me on several other social networking sites: Twitter, Facebook, LinkedIn, Google+.