Xalan
Overview
Xalan is an XSLT stylesheet processor for transforming XML documents into HTML, text, or other XML document types.Download from...
http://xml.apache.org/xalan-j/Basic CLASSPATH...
CLASSPATH=$CLASSPATH:/usr/local/xalan/bin/xalan.jar
CLASSPATH=$CLASSPATH:/usr/local/xalan/bin/xml-apis.jar
CLASSPATH=$CLASSPATH:/usr/local/xalan/bin/xercesImpl.jarTo run the sample applications:
CLASSPATH=/usr/local/xalan/bin/xalansamples.jar:$CLASSPATH
CLASSPATH=/usr/local/xalan/bin/xalanservlet.jar:$CLASSPATHTo run Javascript extensions...
CLASSPATH=/usr/local/xalan/bin/bsf.jar:$CLASSPATHInclude tools.jar. For example:
CLASSPATH=/opt/WebSphere/AppServer/java/lib/tools.jar:$CLASSPATHTo run XSLTC, see Getting Starting with XSLTC.
Sample Applications
The Xalan-Java distribution includes a number of basic sample applications To run set the java executable in your PATH. For example
PATH=/opt/WebSphere/AppServer/java/bin:$PATHcd to the samples subdirectory, and run the java executable.
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.
Perform transformations from the command line
To perform basic transformations from the command line use:
java.org.apache.xalan.xslt.ProcessStandard usage is:
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.
To send output to stdout, omit the -out flag and argument.
Set up Java apps
Here is the basic TrAX procedure for transformations:
- Use the TransformerFactory static newInstance() to instantiate a TransformerFactory.
- Use the TransformerFactory newTransformer(Source stylesheet) method to to produce a Templates object, and generate a Transformer.
- Use the Transformer transform(Source xmlSource, Result transformResult) to apply the transformation instructions (the Templates object) to the XML Source and produce the transformation Result.