|
FAQ
History |
|
Search
Feedback |
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 at
http://xml.apache.org/xalan-j/xsltc_usage.html.
Compiling the Translet
To compile the
article3.xslstylesheet into a translet, execute this command:
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}where:
- -o
transletNameSpecifies the name of the generated translet class (the output class).
The.classsuffix is optional. If not present, it is automatically added to the name specified by the stylesheet argument.- -d
directorySpecifies the destination directory.
(Default is the current working directory.)- -j
jarFileOutputs the generated translet class files into a JAR file named jarFile.jar. When this option is used, only the JAR file is created.
- -p
packageNameSpecifies a package name for the generated translet classes.
- -u
stylesheetURISpecifies 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:
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...]where:
- -u
documentURISpecifies the XML input document with a URI.
documentFilenameSpecifies the filename for an XML input document.
classNameThe translet that performs the transformation. (Here, you can't specify the
.classsuffix, 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.
|
FAQ
History |
|
Search
Feedback |
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.