ࡱ > 7 _ bjbjUU 6 7| 7| X n l l l l RB RB RB 8 B , B Z C : C " D D D P v mQ $ Q 1 0 0 I $ " B m l Q }N z P Q Q m oi D D k
oi oi oi Q D l D oi Q oi oi Qn " d l D C DŢ 8 RB 9^ b v 0 ذ g oi Lab 2 Due Wednesday, February 6
Extensible Style Sheet Language Transformations (XSLT)
In this lab we will be programming in a transformation language called XSLT. XSLT is used to transform an XML document into another XML document (with a different structure). In order to write programs in XSLT, we need an XML parser (XSLT programs are XML documents) and an XSLT interpreter. The parser is called Xerces. The interpreter is called Xalan (Xalan uses Xerces). We can access both by downloading the Java XML Pack - Winter 01 Release from HYPERLINK "http://java.sun.com/xml/downloads/javaxmlpack.html" http://java.sun.com/xml/downloads/javaxmlpack.html. We will make use of some of the other packages found in this bundle later in the course.
In Part I, we will present the details associated with the installation of Xalan and Xerces. In Part II we will test the installation. In Part III we will experiment with using XSLT from within a Java program. Finally, you will be asked to write several XSLT programs and a servlet.
Please submit to blackboard the completed Lab 2 Activities sheet (named Lab2Submission.doc) and the Java servlet (named Courses.java).
You are required to use the same names as used here for files and directories. Otherwise, the lab will be very difficult to grade.
Part I Installing the Jax Pack on Windows NT
1) All of the files that we need to download can be found on Suns web site at HYPERLINK "http://java.sun.com/xml/downloads/javaxmlpack.html" http://java.sun.com/xml/downloads/javaxmlpack.html.
2) Go to this site and select Download (Winter 01), choose Accept and then FTP and download from US East.
3) Double click on the downloaded file and open them up in your zip/unzip software. Choose a directory into which you would like to extract the files (I created a directory on my D: drive called jaxpack and unzipped the files to d:\jaxpack).
4) Look around. Make sure that you have the xalan.jar and xerces.jar files under the jaxp-1.2-ea1 directory. Update your classpath variable so that it contains the following paths:
path to xerces.jar
path to xalan.jar
path to jdk tools.jar
the . which means the current directory
This can be done on an NT machine by choosing start/settings/control panel/system/environment tag and then changing the user variable classpath.
After completing Lab 1 and Lab 2, here is a copy of my classpath settings:
D:\jaxpack\java_xml_pack-winter-01-dev\jaxp-1.2-ea1\xalan.jar;D:\jaxpack\java_xml_pack-winter-01-dev\jaxp-1.2-ea1\xerces.jar;d:\jdk1.2.2\lib\tools.jar;.;D:\jakarta-tomcat-4.0.1\common\lib\servlet.jar
5) You will need to create a batch file so that you can type a simple command like xalan f1.xml f2.xsl f3.wml. An XML document is being transformed by an XSLT program. A WML document is being produced.
Place the following file (xalan.bat) in a directory called c:\batch.
Contents of c:\batch\xalan.bat
java org.apache.xalan.xslt.Process IN %1 -XSL %2 -OUT %3
Place the new directory, c:\batch, in the path variable so that the command interpreter knows where to look for DOS commands. This can be done on an NT machine by choosing start/settings/control panel/system/environment and changing the system variable path to include c:\batch.
After completing Lab 1 and Lab 2, I have my JAVA_HOME set to d:\jdk1.2.2 and my path variable set to a lot of unrelated things but including c:\batch.
Part II Experimenting with XSLT
Figure 2.1 is an xml file called books.xml that contains data on books. Its a copy of the file found on Page 70 of the XSLT Programmers Reference by Michael Kay.
A list of books
1 | Nigel Rees | Sayings of the Century | 8.95 |
2 | Evelyn Waugh | Sword of Honour | 12.99 |
3 | Herman Melville | Moby Dick | 8.99 |
4 | J. R. R. Tolkien | The Lord of the Rings | 22.99 |
Course ID: Math100
Title: Algebra I
Description: Students in this course study introductory algebra.
Prerequisites:
Instructor: Adam Bell 100 CL4 ab@duke.edu 412-111-1122
Course ID: Geom100
Title: Geometry I
Description: Students in this course study how to prove several theorems in geometry.
Prerequisites:
Course ID: Calc100
Title: Calculus I
Description: Students in this course study the derivative.
Prerequisites: Math100 Geom100
Text: Introduction to The Calculus 0-201-43315-X Addison Wesley Longman
Text: Using MathMatica 0-245-48815-X Wolfgram Software
Course ID: Calc200
Title: Calculus II
Description: Students in this course study the integral.
Prerequisites: Calc100
Text: Introduction to The Calculus 0-201-43315-X Addison Wesley Longman
Course ID: Calc300
Title: Calculus III
Description: Students in this course study the derivative and the integral (in 3-space).
Prerequisites: Calc200
Instructor: Ellen Bell 104 Jones Eb@duke.edu 412-344-5612
Text: Introduction to The Calculus 0-201-43315-X Addison Wesley Longman
Course ID: CS1
Title: Introduction to Computer Science I
Description: In this course we study Turing machines.
Prerequisites: Calc100
Course ID: CS2
Title: Introduction to Computer Science II
Description: In this course we study basic data structures.
Prerequisites: Calc200 CS1
Course ID: Philo45
Title: Ethical Implications of Information Technology
Description: In this course we will study the impact of XML on life.
Prerequisites:
Instructor: Susan Smith 102 Smith Hall suem@duke.edu 412-344-2121
Text: The XML Bible 1-833-93399-X Addison Wesley Longman
Text: The Human Use of Human Beings 4-833-93445-X Addison Wesley Longman