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 2: XSLT as an analysis tool

Determine and change analysis criteria

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:  XSLT is meant to change the form of XML, but you can also use it to perform analysis. In this tutorial, the second in a series, the MindMap team creates a system that enables them to pass parameters that not only determine the properties to analyze but also change the desired criteria using Web-based forms. And because it's all in an XSLT stylesheet, the team can change the algorithm or output without recompiling the application.

View more content in this series

Date:  10 Feb 2004
Level:  Intermediate

Activity:  4197 views
Comments:  

Introduction

Should I take this tutorial?

This is the second in a multi-part series detailing the benefits of using XSL Transformations (XSLT). The first tutorial introduced you to the MindMap Research Team, which uses XSLT as part of its analytical toolbox for interpreting data related to cognitive processes. The goal is to give their clients maximum control over their data 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.

This tutorial is designed for programmers who want to change the criteria of an XSL transformation on the fly by using forms to send parameter values through the XSLT. For example, a user could search for a specific item in the XML document by simply entering a search string into a text box using pure XSLT and some application logic either on the server or through a browser's API. If you haven't heard of this kind of activity using XSLT, you can be sure that other people have. Microsoft, in fact, has created a new Office family member named InfoPath to accomplish the same thing. As an XSLT developer, you can forego the costs of InfoPath and simply create your own InfoPath-like applications. So if you're interested in making genuinely dynamic, forms-based XML applications, read on.


Prerequisites

You should have a basic understanding of XSLT and XML before you take this tutorial. In other words, 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 from forms through your stylesheets. You'll also see a fairly significant amount of JavaScript as well, but you can probably get by with the most basic understanding of that language and copy and paste the code you see here, with some customization that I'll walk you through. The same holds true for the Document Object Model (DOM), which is the object model used by JavaScript to access XML nodes for manipulation. You don't need to be a DOM expert to work with this tutorial -- I provide enough of a conceptual overview of the DOM that you should be able to work the examples and move ahead on your own after you have finished.


What is this tutorial about?

You may recall the MindMap team from the first tutorial, but if you don't remember this motivated crew of XSLT maniacs, or if you haven't yet read the first tutorial, a brief reintroduction is in order. MindMap is a fictional research team that works extensively to help university researchers efficiently collect and analyze data. The MindMap team, which has many gigabytes of research articles in their archives, decided to use a process it calls Dynamic XSLT to create a search engine, which the team can port to many different kinds of documents.

One of the first things they leveraged against was the fact that the xsl:param element is a hardy tool for processing XSLT from the server and creating interactions with Web forms. It allows users to supply values through name/value pairs and process nodes based on those values. This means you can call different templates dynamically on the client based on user input to display different sets of data based on user events.

The team realized that you can do the same sort of thing on the client side in Mozilla-based browsers such as Netscape 7.0 and in Internet Explorer 5.0 and higher. This allowed them to create XSLT-based applications that required nothing more than a browser to work effectively, no matter what kind of IT environment their clients were using.

I could have chosen a server technology to demonstrate the same concepts -- that of passing parameters to and from a stylesheet to change the search context -- but I like the MindMap approach because anyone can use it. You don't need access to a Web server to work with this tutorial. All you need is the willingness to download and install Netscape or Mozilla. You'll see that an API for working with XML data is an API, whether it's client-side or server-side, and that the key is managing the object methods and properties of whatever API you're using to make a transformation dynamic.

In this tutorial, you'll use XSLT to accomplish the following:

  • Create the necessary HTML form fields
  • Build named templates for analyzing properties
  • Pass parameters to the templates
  • Build a user interface to let users change the algorithm parameters
  • Handle the parameters in your application code

Tools

Make sure you install and test the following tools before beginning the tutorial:

  • Mozilla 1.2 or higher. Download it from http://www.mozilla.org/.
  • A text editor that supports UTF-8 (http://www.cl.cam.ac.uk/~mgk25/unicode.html) or an XML editor (http://www.garshol.priv.no/download/xmltools/cat_ix.html#SC_XMLEditors).

Finally, you'll want to download the files referred to throughout this tutorial in file x-analysfiles.zip. You should download them before starting the tutorial so that you can follow along more easily, because you'll often encounter code fragments taken from longer files and it helps to view those fragments in the context of the overall file.

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=138113
TutorialTitle=Analyze with XSLT, Part 2: XSLT as an analysis tool
publish-date=02102004
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.