Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Analyze with XSLT, Part 3: Layering XSLT stylesheets

Layer and use chain transformations to create procedural techniques

Chuck White (chuck@tumeric.net), XSLT consultant and Web engineer, Freelance Developer
Chuck White, a Studio B author, has been working with XML since before its official inception in February, 1998. He was co-author of Mastering XML Premium Edition (with Linda Burman and the W3C's XML Activity Lead, Liam Quin) and author of Mastering XSLT, both from Sybex Books. His latest books are Developing Killer Web Apps with Dreamweaver MX & C# (also for Sybex Books) and HTML, XHTML, and CSS Bible, 3rd Edition for Wiley, for which he is co-author with Steve Schafer. Chuck is currently working with the XSL Team at eBay as a project consultant and Web engineer.

Summary:  In this third tutorial in a multi-part series on the benefits of using XSLT, the MindMap Team discovers the need to perform some analyses that require procedural techniques. Because XSLT is not a procedural language, this tutorial explains how to layer and use chain transformations to get around some of the limitations this structure provides. The tutorial demonstrates how to use named templates to mimic side effects, and how external documents are layered together to interoperate.

View more content in this series

Date:  16 Mar 2004
Level:  Intermediate PDF:  A4 and Letter (196 KB | 28 pages)Get Adobe® Reader®

Activity:  3131 views
Comments:  

Introduction

Should I take this tutorial?

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.


What is this tutorial about?

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:

  1. A source document named CodeLibrary.xml containing the data that will be displayed
  2. A lookup table named tab_images.xml for storing information about the tabs
  3. A re-usable generic XSLT stylesheet named tabs.xsl for generating the tabs
  4. A stylesheet named display.xsl for displaying the data and for importing tabs.xsl for navigation
  5. A stylesheet named addContent.xsl for storing the additional templates that will be called from the main stylesheet
  6. A stylesheet named stringbreak.xsl for handling long lines of unbroken text

Tools

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.

1 of 11 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML
ArticleID=138322
TutorialTitle=Analyze with XSLT, Part 3: Layering XSLT stylesheets
publish-date=03162004
author1-email=chuck@tumeric.net
author1-email-cc=dwxed@us.ibm.com

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.