|
|
|||
|
Installing and Using Xalan with JDK6 in Linux RHEL506-Mar-2008Xalan is an Apache project XSLT processor. There are two main implementations of Xalan, one written in Java and another in C++. I'll be covering only the Java version (Xalan-J) here.
The ProblemDownload, install, and use Xalan-J on a RHEL 5 platform.The SolutionI previously installed Sun's JDK rather rather than using the GNU Complier for Java (GCJ) which can be installed by default with RHEL5. See my Notes on Tomcat Solr and RHEL5 for details of installing Sun's Java and using jpackage to manage multiple java installations on one RHEL5 machine.
Download Xalan binaries
Install Xalan
CLASSPATH approach
cd /home/rcapra/javalib unzip xalan-j_2_7_1-bin.zipThis should create a subdirectory called xalan-j_2_7_1 that will contain the files you need to run Xalan. Four files need to be included in your CLASSPATH: xalan.jar xercesImpl.jar xml-apis.jar serializer.jar.Once these are in your CLASSPATH, you should be ready to try it out (see the section below on "Running Xalan").
Java Extension Directory
mkdir /usr/java/packages/lib/ext cp /home/rcapra/javalib/xalan-j_2_7_1/*.jar /usr/java/packages/lib/extJava should now find the jar files.
Another approach
Running Xalan
java com.sun.org.apache.xalan.internal.xslt.Process -IN in.xml -XSL in.xsl -OUT out.xmlThere is additional information on running Xalan from the command line on the Xalan website page, http://xml.apache.org/xalan-j/commandline.html False StartsSince JDK 1.4, Xalan has been packaged with Sun's JDK. So why download and install the most recent version when there is one already included with the JDK? I only planned to do basic XLST processing, so I figured that the version included with the JDK would be fine.To use the version packaged with the JDK, there is a slightly different path to the Process class. com.sun.org.apache.xalan.internal.xslt.ProcessHowever, trying: java com.sun.org.apache.xalan.internal.xslt.Process -IN in.xml -XSL in.xsl -OUT out.xmlGave the following error: Exception in thread "main" java.lang.NoSuchMethodError: mainIt turns out that there is a bug that has been around since JDK 1.4 (and still appears to be present in JDK 6) that there is no "main" for the Process class. According to this posting, the main class is incorrectly _main. An obvious workaround (which I have seen mentioned in the post above and elsewhere) would be to write a wrapper class. I decided that once I wasn't getting the packaged version "for free" so to speak, that I might as well download and install the latest release. Links/References |
|
|||
|
Prepared by
r c a p r a 3 [at] u n c [dot] e d u
Last modified: March 07 2008 01:20:33 Copyright 2000-2008 by Robert G. Capra III |