Introduction
This is the third in a multi-part series detailing the benefits of using XSL Transformations (XSLT). The first tutorial, Analyzing non-XML data with XSLT, introduced you to MindMap, a fictional research team that uses XSLT as part of its analytical toolbox for interpreting data related to cognitive processes. The goal is to maximize flexibility for their clients by leveraging the ability to change algorithms and methods without having to recompile applications. The MindMap team deals with several aspects of the process, from data acquisition to visualization to tying the data in to other resources.
You should have a basic understanding of XSLT and XML before
you take this tutorial. As in Part 2 of the series,
XSLT as an analysis tool,
if you aren't familiar with what an XSLT parameter does and how it works, you'll find some of this
material a little difficult. This is because this tutorial keys in on the use
of the xsl:param element as you learn how to pass
parameters through various layers within the framework of your XSLT
application. In fact, I recommend that you read the first tutorial as well, because
it lays the groundwork for the entire series.
If you're looking to discover processes for making XSLT act more like a procedural programming language, this tutorial demonstrates how you can change the value of variables and parameters by calling them through different iterations of the source tree. You'll also discover the power of using multiple documents to layer templates and even XML documents to help achieve these effects.
Some of the more common navigation systems found on the Web today are tab-based systems. The MindMap team has found a number of different occasions to develop such a system, and so they decided they needed to come up with a flexible solution that would work across a number of different scenarios without too much adaptation. The team wanted to develop a tab-based navigation system using XSLT that would also work both on the client side and on servers. This tutorial examines their solution, which involves XML lookup tables and XSLT, and a layering system involving multiple passes of same-named parameters.
The solution that the MindMap team ultimately decided on for a tabbed navigational system took the same basic form as that presented in this tutorial. The data used might be different depending on the task, but the transformations are pretty much the same. The modular Web application they developed consists of six components, all created in this tutorial:
- A source document named
CodeLibrary.xmlcontaining the data that will be displayed - A lookup table named
tab_images.xmlfor storing information about the tabs - A re-usable generic XSLT stylesheet named
tabs.xslfor generating the tabs - A stylesheet named
display.xslfor displaying the data and for importingtabs.xslfor navigation - A stylesheet named
addContent.xslfor storing the additional templates that will be called from the main stylesheet - A stylesheet named
stringbreak.xslfor handling long lines of unbroken text
Make sure you install and test the following tools before beginning the tutorial:
- Internet Explorer 5.0 or higher (http://www.microsoft.com/windows/ie/default.asp).
- You can download the files referred throughout this tutorial in file x-layerfiles.zip. You should download them before starting the tutorial so that you can follow along more easily.
Generally, when passing parameters to and from XSLT stylesheets, you pass to and from a server-side environment, such as a J2EE environment or some other Web application server. To reach the broadest audience, this tutorial uses Internet Explorer as the application server so you can focus on the concept of passing parameters. This means that if you're using a Linux or Unix box, you'll have a hard time running the examples unless you can port it to your application server. This would require some knowledge of how your Web application server manages the Document Object Model (DOM) and is beyond the scope of this tutorial, but the concepts presented here are certainly portable to any server environment.

