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 profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

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:  8035 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



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=