Lab 6B

Building an XML Server

XML Server Architecture

XML server architecture

Instructions

STEP 1 -- Get the tools you'll need for this lab.

ToolOfficial SiteLocal CacheSizeInstallation Procedure
1 Java Development Kit (JDK)
  • Java Runtime Environment (JRE)
  • Compiler, debugger, other tools
  • Java 2 SDK, Standard Edition (J2SE)
  • Software Development Kit (SDK)
j2sdk-1_3_1-win.exe from java.sun.com j2sdk-1_3_1-win.exe from keller.com 32.8 MB
  1. Run the downloaded file directly; it self-extracts.
  2. Install it at C:\tools\jdk1.3.1.
  3. Reboot.
  4. Problems? Here are details.
2 Tomcat servlet wrapper
  • An enhanced Apache-like web server
  • Includes the Java API for XML Processing (JAXP, in a Java source file named javax.xml)
  • Class libraries: a parser API, a transformer (stylesheet) API, W3C's DOM, XML.org's SAX
  • Documented here
jakarta-tomcat-3.3.1.zip from apache.org jakarta-tomcat-3.3.1.zip from keller.com 4.7 MB Unzip it into C:\tools\jakarta-tomcat-3.3.1
3 The Xalan XSLT processor
  • Applies XSLT stylesheets to XML data
  • Includes the Xerces XML parser
  • Documented here
xalan-j_2_4_D1-bin.zip from apache.org xalan-j_2_4_D1-bin.zip from keller.com 9.3 MB Unzip it into C:\tools\xalan-j_2_4_D1

STEP 2 -- Install the Java archives (JARs)
Copy the following files from
C:\tools\xalan-j_2_4_D1\bin
to
C:\tools\jakarta-tomcat-3.3.1\lib\apps

JAR NameDescription
xalan.jar XSL processor
xalanservlet.jar sample servlets
xml-apis.jar JAXP (see below)
xercesImpl.jar JAXP-compliant XML parser

STEP 3 -- Run the Tomcat server

STEP 4 -- Run a servlet that processes XML

STEP 5 -- Select some different XML and XSL to process

STEP 6 (Optional/Advanced) -- Install your own XML data and stylesheet(s)
The directory in which to install these files is:
C:\tools\xalan-j_2_4_D1\samples\SimpleTransform

Caveat: Xalan is fussy about the stylesheet namespace. Be sure to declare it as:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
STEP 7 (Optional/Advanced) -- Read source code
Read the Java source code for servlet.XSLTServletWithParams to get an idea of the architecture of an XML-generating program. The full pathname of this file is:
C:\tools\xalan-j_2_4_D1\samples\servlet\XSLTServletWithParams.java
Observe that the crucial line of code -- in which the stylesheet transformation is done -- is line 130:
transformer.transform(xmlSource, new StreamResult(out));