http://xml.apache.org/http://www.apache.org/http://www.w3.org/

What's New
XSLTC Translets

Overview
Getting Started

FAQs

Sample Apps
Command Line

Usage Patterns

TrAX
API (Javadoc)

Extensions
Extensions Library

Release Notes

Xalan 2 Design
XSLTC Design

Bugs
Testing

Credits
XSLTC Credits

Downloading what you need
 

To use Xalan, you need the following:

  • The JDK or JRE 1.1.8, 1.2.2, or 1.3
  • xalan.jar
  • xerces.jar (or another XML Parser)

You can get the JDK or JRE from ibm.com/java/jdk/ or java.sun.com.

Download xalan-j_2_1_0.zip or xalan-j_2_1_0.tar.gz. Both of these files contain Xalan-Java version 2.1.0 (with xalan.jar) and xerces.jar from Xerces-Java version 1.4. You can use a zip or tar utility to expand these files into a full build.

If you plan to run XSLT extensions, you need bsf.jar, which is included in the Xalan-Java distribution. If you plan to run XSLT extensions implemented in Javascript or another scripting language, you will need one or more additional files as indicated in extensions language requirements.


Setting up the system classpath
 

At the very minimum, you must include xalan.jar and xerces.jar (or another conformant XML parser -- see Plugging in a Transformer and XML parser) on the system classpath. To run the sample applications, include xalansamples.jar (all samples other than the servlet) and xalanservlet.jar. To run extensions, include bsf.jar. All these JAR files are distributed with Xalan-Java. For extensions implemented in JavaScript or another scripting language, see extensions language requirements to identify any additional JAR files you must place on the classpath and where you can get them.

If you are using JDK or JRE 1.1.8, also include classes.zip on the classpath. If you are using JDK or JRE 1.2, include tools.jar on the classpath.

NoteIf you are using xerces.jar from a Xerces release that is more recent than Xerces-Java version 1.4, you may need to put xerces.jar before xalan.jar on the classpath. Both JAR files include the org.w3c.dom packages. The Xerces team is tracking updates to DOM level 2, and the Xerces parser may require access to updates in these packages.

Trying out the samples
 

The Xalan-Java distribution includes a number of basic sample applications. These samples are easy to run, and you can review the source files -- all of which are brief -- to see just how they work.

To run the samples, do the following:

  1. Set up your classpath (see above), including xalansamples.jar and (for the servlet) xalanservlet.jar.
  2. Be sure the java executable is on your path.
  3. Go to the samples subdirectory containing the sample (use the DOS shell if you are running Windows).
  4. Use the java executable to run the sample from the command line.
  5. Examine the application source and result files.

For example, go to the SimpleTransform subdirectory and issue the following command:

java SimpleTransform

The sample writes the transformation result to a file (birds.out). To see how the example works, examine the source files: birds.xml, birds.xsl, and SimpleTransform.java.

The extensions examples require additional JAR files on the classpath, and the procedure for running the sample applet and sample servlet is different. For more information about all the samples, see Xalan-Java Samples.


Performing your own transformations from the command line
 

java.org.apache.xalan.xslt.Process provides a basic utility for performing transformations from the command line. You use this utility, for example, to run several of the extensions samples. The command line for most standard transformations is as follows:

java org.apache.xalan.xslt.Process -in xmlSource
    -xsl stylesheet -out outputfile

where xmlSource is the XML source file name, stylesheet is the XSL stylesheet file name, and outputfile is the output file name.

If you want the output to be displayed on the screen, simply omit the -out flag and argument.

You can use this utility to try out XSL stylesheets you have written, to make sure they do what you expect with the XML source files they are designed to transform. The utility provides useful messages if the source file or stylesheet is not well formed. For more information, see Command-Line Utility.


Setting up your own Java applications
 

You can start by using your own XML source files and XSL stylesheets with the sample applications, which illustrate a number of the basic usage patterns.

Here is the basic TRaX procedure to keep in mind when you set up a transformation:

  1. Use the TransformerFactory static newInstance() method to instantiate a TransformerFactory.

  2. Use the TransformerFactory newTransformer(Source stylesheet) method to process the transformation instructions in an XSLT stylesheet Source (producing under the covers a Templates object) and generate a Transformer.

  3. Use the Transformer transform(Source xmlSource, Result transformResult) method to apply the transformation instructions (the Templates object) to the XML Source and produce the transformation Result.

For more information about this procedure and its variations, see Basic Usage Patterns.



Copyright © 2000 The Apache Software Foundation. All Rights Reserved.