The JavaTM Web Services Tutorial
Home
TOC
Index
PREV TOP NEXT
Divider

Transforming from the Command Line

When you are running a transformation from the command line, it makes a lot of sense to use XSLTC. Although the Xalan interpreting transformer contains a command-line mechanism as well, it doesn't save the pre-compiled byte-codes as translets for later use, as XSLTC does.

There are two steps to running XSLTC from the command line:

  1. Compile the translet.
  2. Run the compiled translet on the data.

Note: For detailed information on this subject, you can also consult the excellent usage guide at http://xml.apache.org/xalan-j/xsltc_usage.html.

Compiling the Translet

To compile the article3.xsl stylesheet into a translet, execute this command:

java org.apache.xalan.xsltc.cmdline.Compile article3.xsl
 

Note: For version 1.3 of the Java platform, you'll need to include the appropriate classpath settings, as described in Compiling and Running the Program.

The result is a class file (the translet) named article3.class.

Here are the arguments that can be specified when compiling a translet:

java org.apache.xalan.xsltc.cmdline.Compile
    -o transletName -d directory -j jarFile
    -p packageName {-u stylesheetURI | stylesheetFile }
 

where:

Running the Translet

To run the compiled translet on the sample file article3.xml, execute this command:

java org.apache.xalan.xsltc.cmdline.Transform 
    article3.xml article3
 

Note: Again set the classpath, as described in Compiling and Running the Program, if you are running on version 1.3 of the Java platform.

This command adds the current directory to the classpath, so the translet can be found. The output goes to System.out.

Here are the possible arguments that can be specified when running a translet:

java org.apache.xalan.xsltc.cmdline.Transform
    {-u documentURI | documentFilename} 
    className [name=value...]
 

where:

Divider
Home
TOC
Index
PREV TOP NEXT
Divider

This tutorial contains information on the 1.0 version of the Java Web Services Developer Pack.

All of the material in The Java Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.