XSLT

XSLT

What is xslt ?

So you've decided to use XML to capture your information in a robust, hierarchical fashion. You are creating your structured data, maybe even using Cascading Stylesheets (CSS) to render your documents as they exist today, and you are building a collection of information following a consistent model.

Congratulations! Now what are you going to do?

The information you've described is probably in a hierarchy that is organized in a way important to you because you are the one creating it. This hierarchy you've chosen may not be the hierarchy that makes sense for those processes or other people that need to work with your information. Or, perhaps you have your own reasons to reorganize your information in different ways, with different orientations to fulfill your own different requirements, to emphasize your information differently for your colleagues, to hide certain private information from your customers, etc.

Or, perhaps unfortunately you haven't been able to create your information in the best structure for all your needs. To accommodate how your information is presented you may have been restricting how your information has been and is being created, making it difficult to relate or pull together while being forced to think of a single end result at all times.

In short, the way you have chosen to capture or describe your information isn't always the way you want to present or use your information.

Welcome to XSLT!

The Extensible Stylesheet Language Transformations (XSLT) W3C recommendation describes a transformation vocabulary used to specify how to create new structured information from existing XML documents.

Unlike with a programming language, you don't need to be a programmer to successfully describe how to transform your information. XSLT implements transformation "by example", not just "by program logic", and builds in support for the kinds of transformation typically needed to present information.

Your objective, as an XSLT stylesheet writer, is to give an XSLT engine examples of how each of the constructs in your information is supposed to be structured once it has been transformed. You create these examples as "templates" of the result and you tell the engine when these templates get added to the resulting tree your transformation is creating. Your stylesheet templates can include your instructions to the XSLT engine to hunt down information anywhere in your input XML file, or many XML input files, to fill in holes in your template where your own information belongs.

When using the Extensible Stylesheet Language (XSL) formatting objects to present your information, your stylesheet objective is to transform your information into a hierarchy exclusively comprised of the XSL formatting object vocabulary. A rendering engine then takes this result hierarchy and interprets the semantics of the XSL vocabulary to produce your desired rendition, all without using a single construct of your own vocabulary, because you've transformed your own information into rendering information.

With XSLT you are not restricted to present your information in the same order you created it, nor are you required to present all of your information. Also, you can traverse your source XML multiple times if you need to reuse your information more than once in a single result, perhaps to simultaneously create tables of content and internal cross references described abstractly in your raw structured content.

The XSLT recommendation describes how XSLT engines can choose to support different ways to serialize the templates you have added, in combination with the information you glean from your source tree, to the result tree. Your result can be realized using XML syntax conventions, HTML syntax conventions (with or without CSS) or just simple text.

Think of the possibilities: with XSLT you can take your structured XML information and synthesize new instances for your colleagues and customers to use, or build HTML/CSS web pages from data stores, or feed other systems with flat text representations of your data, or create operating system scripts, etc.

This gives you the freedom to organize the information the way you want from the beginning, to best meet your own business requirements, and still fulfill your obligations and desires to utilize your information in a myriad of ways downstream.

Discover how XSLT can be used today with your information!