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]

Create multi-purpose Web content with XSLT

Repurpose content without altering data

Nicholas Chase, a Studio B author, has been involved in Web site development for companies such as Lucent Technologies, Sun Microsystems, Oracle, and the Tampa Bay Buccaneers. Nick has been a high school physics teacher, a low-level radioactive waste facility manager, an online science fiction magazine editor, a multimedia engineer, and an Oracle instructor. More recently, he was the Chief Technology Officer of Site Dynamics Interactive Communications in Clearwater, Florida, USA, and is the author of four books on Web development, including XML Primer Plus (Sams). He loves to hear from readers and can be reached at nicholas@nicholaschase.com.

Summary:  This tutorial is for developers who want to create content that can be repurposed for a variety of presentations without affecting the original data. It explains how to create a Java servlet that determines the means by which the data is being viewed and uses XML and XSLT to provide the appropriate presentation. It also includes information on using the servlet as the basis for a Web service.

Date:  18 Mar 2003
Level:  Introductory PDF:  A4 and Letter (181 KB | 30 pages)Get Adobe® Reader®

Activity:  5315 views
Comments:  

Introduction

Should I take this tutorial?

This tutorial is for developers who want to create content that can be repurposed for a variety of presentations without affecting the original data. It explains how to create a Java servlet that determines the means by which the data is being viewed and uses XML and XSLT to provide the appropriate presentation. It also includes information on using the servlet as the basis for a Web service.

This tutorial uses Java to transform XML data, but the XSLT concepts are common to other languages as well. It assumes that you are familiar with XML and with XSL Transformations, but the actual transformations themselves are a minor part of the tutorial. An understanding of Java development is helpful, but not required.

What is this tutorial about?

As the Web grows, it is increasingly being pulled in opposite directions. On the desktop, Web pages and the browsers that display them are becoming more and more complex as companies strive for presentations that are eye-catching while still being functional. At the same time, Web content is increasingly being repurposed for devices such as pagers and mobile phones that, while more robust than they used to be, are still incapable of handling some of these more complex pages. In addition, the future will see more and more content accessed as Web services, which typically requires an entirely different structure.

This tutorial takes a series of headlines stored in an XML file and explains how to automatically choose the proper XSLT style sheet to display them in a traditional browser or a mobile browser, and to return them as the response for a Web service, both through a proxy created in WebSphere Studio V5 and directly.

The tutorial covers:

  • The basic environment
  • Creating a servlet
  • Performing a transformation
  • Selecting the appropriate style sheet
  • Creating and accessing the Web service

Tools

You can gain a good understanding of the concepts behind this tutorial without actually executing the examples, but should you choose to follow along, the following tools should be installed and tested prior to starting the tutorial:

  • Although not required, all of the necessary tools for creating XML and XSLT files and Java classes, as well as creating the Web service proxy, are available within IBM's WebSphere Studio V5. WebSphere Studio also includes a test server environment for running the servlet, so you can accomplish all of the development in this tutorial with this one tool.
  • To see the mobile phone examples, you can download the Openwave SDK, which includes a simulator that works over HTTP. Download the SDK at http://developer.openwave.com/download/product_62.html. The examples use only HTTP, so the WAP extension is not necessary for this tutorial. (Phone screenshots provided by Openwave.)

If you choose not to use WebSphere Studio or another development environment, you can also complete the examples using:

  • A text editor to create and XML and XSLT files.
  • A Java development environment such as Sun's Java 2 Standard Edition version 1.4, available at http://java.sun.com/j2se/1.4/. Version 1.4 has built-in XML support.
  • A servlet-capable Web server such as IBM's WebSphere Application Server, or Apache Tomcat, available at http://tomcat.apache.org/tomcat-4.1-doc/. (Even if you use WebSphere Studio to create and test the application, you'll need a server on which to deploy your production application.)

1 of 9 | 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=138458
TutorialTitle=Create multi-purpose Web content with XSLT
publish-date=03182003
author1-email=nicholas@nicholaschase.com
author1-email-cc=

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.