Home
TOC Index |
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:
Note: For detailed information on this subject, you can also consult the excellent usage guide athttp://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.Compilearticle3.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 -otransletName
-ddirectory
-jjarFile
-ppackageName
{-ustylesheetURI
|stylesheetFile
}
- -o
transletName
- Specifies the name of the generated translet class (the output class).The
.class
suffix is optional. If not present, it is automatically added to the name specified by the stylesheet argument.- -d
directory
- Specifies the destination directory. (Default is the current working directory.)
- -j
jarFile
- Outputs the generated translet class files into a JAR file named jarFile.jar. When this option is used, only the JAR file is created.
- -p
packageName
- Specifies a package name for the generated translet classes.
- -u
stylesheetURI
- Specifies the stylesheet with a URI such as
http://myserver/stylesheet1.xsl
.stylesheetFile
- (No flag) The pathname of the stylesheet file.
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 {-udocumentURI
|documentFilename
}className
[name
=value
...]
- -u
documentURI
- Specifies the XML input document with a URI.
documentFilename
- Specifies the filename for an XML input document.
className
- The translet that performs the transformation. (Here, you can't specify the
.class
suffix, the same way you omit it when running a java application.)name=value
...
- Optional set of one or more stylesheet parameters specified as name-value pairs.
Home
TOC Index |
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.