You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sb...@apache.org on 2001/04/17 21:07:32 UTC
cvs commit: xml-xalan/java/xdocs/sources/xsltc README README.APACHE README.api README.xslt README.xsltc README2
sboag 01/04/17 12:07:31
Added: java/xdocs/sources/xsltc README README.APACHE README.api
README.xslt README.xsltc README2
Log:
Initial XSLTC docs.
Revision Changes Path
1.1 xml-xalan/java/xdocs/sources/xsltc/README
Index: README
===================================================================
=======================================================================
README FILE FOR THE SUN XSLT COMPILER
Preview Version 6
April, 2001
Copyright (c) Sun Microsystems, 2001
=======================================================================
The Sun XSLT Compiler (XSLTC) is a Java-based tool for compiling XSL
stylesheets into extremely lightweight and portable Java byte code.
The Sun XSLTC Java Runtime environment can then process XML files
against these compiled stylesheets (Translets) to generate any manner
of output per the style-sheet instructions.
This preview version of the XSLT Compiler can be run on any
platform -- including UNIX, Windows, NT, Mac -- that supports
Java2 or later. The Translets (compiled stylesheets) can be run on any
Java platform including a Palm Pilot with J2ME CLDC
(Java 2 Micro Edition, Connected Limited Device Configuration).
While the compiler itself requires Java2,translets are designed to run
anywhere Java is available.
Almost all functions of the XLST 1.0 language are implemented;
more than enough to show you how this new approach to XSLT works
and its advantages! Using the samples provided, you will be able
to see for yourself. Also, demos for the Palm Pilot, Applets, and
Servlets are provided.
-----------------------------------------------------------------------
ATTRIBUTIONS
-----------------------------------------------------------------------
The XSLT Compiler program uses the CUP Parser Generator
for Java, Copyright 1996-1999 by Scott Hudson, Frank Flannery,
C. Scott Ananian. For more details, please see:
http://www.cs.princeton.edu/~appel/modern/java/CUP/
The XSLT Compiler program also uses a modified version of the
Byte Code Engineering Library (BCEL), formerly known as
(JavaClass API), Copyright 2000 Markus Dahm.
** Please note that this additional package, BCEL, is
** needed in order to generate the class files from the compiler.
** Without the BCEL package, this preview version of the
** compiler WILL NOT WORK. BCEL is freely available for
** download as described below.
-----------------------------------------------------------------------
REQUIRED PACKAGE
-----------------------------------------------------------------------
BCEL (formerly JavaClass) by Markus Dahm has been
used to automatically create class files from the XSLT compiler output.
You must obtain the BCEL.jar file and install it before using the
XSLT compiler.
The simplest way to download the BCEL.jar file from
http://bcel.sourceforge.net/downloads.html
is to use the "JAR file (without docs)" link.
You may want to obtain the precompiled class files and documentation.
To download them to a Unix system:
1) Choose the "latest version (Precompiled + docs)"
Gzipped Tar-File or ZIP-File link.
2) Unpack and expand the downloaded BCEL files in your
download directory (e.g., /usr/local).
3) Change directory to BCEL.
4) Create the jar file BCEL.jar.
From within the BCEL directory, you can either use the
included GNUmakefile or create the jar yourself.
To use the GNUmakefile, type the command 'make jar'.
To create the jar yourself, type the command:
jar cvf BCEL.jar `find de gnu -name \*.class` listclass.class
To download the precompiled class files and documentation
to a Windows system:
1) Choose the "latest version (Precompiled + docs)"
ZIP-File link.
2) Unzip the downloaded BCEL files in your
download directory.
3) Change directory to BCEL and from a DOS command line,
type the command:
jar -cvf BCEL.jar de\fub\bytecode\classfile\*.class
gnu\regexp\*.class listclass.class
To complete the BCEL setup:
1) Install XSLTC, as described in the section below,
"HOW TO INSTALL XSLTC AND RUN THE SAMPLES."
2) Copy the BCEL.jar file into the "lib" directory
under your "xsltc" directory.
You are now set to run the XSLT compiler.
------------------------------------------------------------
ADDITIONS FROM VERSION 5 (of the PREVIEW COMPILER)
------------------------------------------------------------
Support for
- Simplified Stylesheets
- id() and key() in match patterns
------------------------------------------------------------
XSLT 1.0 Features Not Suported in PREVIEW VERSION 6
------------------------------------------------------------
The following XSLT 1.0 features are not yet supported:
* Nonstatic external Java methods.
You may call static Java functions
using a namespace prefix matching the class name that is
associated with the following URL:
http://www.sun.com/xsltc/java/YourJavaClass
* Namespace axis
------------------------------------------------------------
LIST OF FILES
------------------------------------------------------------
The files included in this preview package are as follows:
xsltc-1_0-alpha5-bin.zip
<install dir>/xsltc
LICENSE.txt (license file)
XSLTCprn_lg.txt (copyright notice)
README (this file)
README.api (describes Translet API)
README.xslt (describes runtime command line interface)
README.xsltc (describes compiler command line interface)
bin
xslt (runtime for Unix)
xsltc (compiler for Unix)
xslt.bat (runtime for DOS)
xsltc.bat (compiler for DOS)
demo
README
TransletDemo.prc (Palm Pilot install file)
lib
xml.jar
xsltc.jar
xsltcrt.jar ('rt' = runtime)
[BCEL.jar goes here] (see REQUIRED PACKAGE above)
samples
set of xml and xsl files for you to try
src
subset of the runtime package to complement README.api
plus an Applet demo and a servlet demo
com/sun/xslt/demo/servlet
README.servlet (describes Servlet demo)
com/sun/xslt/demo/applet
README.applet (describes Applet demo)
------------------------------------------------------------
HOW TO INSTALL XSLTC AND RUN THE SAMPLES
------------------------------------------------------------
1. Unzip the files in a directory of your choice, for example
from the user directory '/home/user1', the distribution
zip file can be unzipped using the jar command as:
jar xvf xsltc-1_0-alpha5-bin.zip
The subdirectory 'xslt' will be created in '/home/user1'.
2. Set the XSLT environment variable to point to your installation
directory. Set your PATH environment variable to include
the bin directory of XSLT.
For example, in the bash shell:
export XSLT=/home/user1/xslt
export PATH=$XSLT/bin:$PATH
3. Compile the stylesheet to produce a Java class file.
For example, on the Unix platform, to compile the play1.xsl
stylesheet for the play.xml document:
cd /home/user1/xsltc/samples
xsltc play1.xsl
The compiled stylesheet will be in the main Java class file
'play1.class'
NOTE: The 'xlstc' shell script adds the required jars to your CLASSPATH
For example, on the Windows platform, to compile the play1.xsl
stylesheet for the play.xml document:
set classpath=c:\xsltc\samples;c:\xsltc\lib\xsltc.jar;
c:\xsltc\lib\xsltcrt.jar;c:\xsltc\lib\xml.jar;
c:\xsltc\lib\BCEL.jar;.
cd c:\xsltc\samples
java com.sun.xslt.compiler.XSLTC play1.xsl
4. Use the compiled Java class file (play1.class) to transform
the example XML document.
For example, on the Unix platform:
xslt play.xml play1
For example, on the Windows platform:
java com.sun.xslt.runtime.DefaultRun play.xml play1
The result is sent to standard output.
NOTE: When running the compiled stylesheet, you
just specify the name of its Java class, not its
file name (e.g., play1, not play1.class).
You do not include the ".class" extension, nor
the path to the class. The class is found by means
of the Java CLASSPATH variable. If you run
the translet from a directory other
than the directory in which the compiled
stylesheet class is located, you need to add
that directory to your Java CLASSPATH. Also, you
need to remove directories from your CLASSPATH
for prior installations of XSLTC and any references
to Sun's project X parser (com.sun.xml.tree)
installed from some other XML application/tool.
NOTE: The javadocToHtml sample calls external Java methods
from the JavadocFormatter class. Before compiling the
javadocToHtml.xsl stylesheet, compile the
JavadocFormatter class using 'javac'.
------------------------------------------------------------
END OF README
1.1 xml-xalan/java/xdocs/sources/xsltc/README.APACHE
Index: README.APACHE
===================================================================
README.APACHE
=====================================================================
Entire source tree and support packages are located in the single jar
file 'apache.jar'.
Installation
-------------
(1) create directory [Root], unpack 'apache.jar' there.
ex) % cd /tmp; mkdir xsltc_apache
% cd xsltc_apache
copy apache.jar to xsltc_apache directory
% jar xvf apache.jar
cleanup
% rm -rf META-INF apache.jar
Unpacking the jar file will result in the following tree:
[Root]
External/
BCEL/ ... contains BCEL.jar
JLex/ ... contains JLex.jar
java_cup/ ... contains java_cup.jar, runtime/runtime.jar
xml-tr2/ ... contains xml.jar
bin/
xslt
xsltc
doc/
api/ ... contains javadoc for api
src/
GNUmakefile
GNUmakefile.allinc
docs/
LICENSE.txt
Message.txt
README
README.api
README.xslt
README.xsltc
XSLTCprn_lg.txt*
xsltcA3.txt
org/
apache/
xalan/
xsltc/
(src tree) ... all the source code files
The 'src tree' is a hierarchy of the following packages:
org.apache.xalan.xsltc
org.apache.xalan.xsltc.compiler
org.apache.xalan.xsltc.compiler.util
org.apache.xalan.xsltc.dom
org.apache.xalan.xsltc.runtime
org.apache.xalan.xsltc.util
org.apache.xalan.xsltc.util.getopt
(2) make bin programs executable
% chmod +x bin/*
(3) set env variable to point to top of directory [Root]
ex) % setenv XSLT /tmp/xsltc_apache
(4) compile sources (uses gnu make and the provides 'GNUmakefile'). This
will create java classes in [Root]/classes, e.g. /tmp/xsltc_apache/classes.
(No need to set your CLASSPATH variable.)
ex) % cd src; gmake again
Note: the 'again' target forces everything to be built from scratch,
including the java_cup source files. Subsequent builds can be done
using the 'classes' target.
(5) make the javadoc
ex) % gmake jdoc
(6) add bin directory to your executable path,
ex) % set path=($XSLT/bin $path)
(7) test distribution, given a stylesheet (test.xsl) and an input xml doc
(test.xml), and be sure current working directory (.) is in your
CLASSPATH.
% xsltc test.xsl ... creates translet, test.class
% xslt test.xml test ... runs translet on xml input
1.1 xml-xalan/java/xdocs/sources/xsltc/README.api
Index: README.api
===================================================================
============================================================
README FILE FOR THE SUN XSLT COMPILER API
Preview Version 5
February, 2001
Copyright (c) Sun Microsystems, 2001
============================================================
The Sun XSLT Compiler (XSLTC) is a Java-based tool for
compiling XSL stylesheets into extremely lightweight and
portable Java byte code. The Sun XSLTC Java Runtime environment
can then process XML files against these compiled stylesheets
(Translets) to generate any manner of output per the style-
sheet instructions.
CONTENTS OF THIS DOCUMENT:
1. HOW TO INCLUDE TRANSLETS IN YOUR APPLICATIONS
2. FULL CODE EXAMPLE 1, (uses a SAX DocumentHandler).
3. COMPILING AND RUNNING THE EXAMPLE
4. FULL CODE EXAMPLE 2, (uses DefaultSAXOutputHandler).
5. APPENDIX (TextOut and DefaultSAXOutputHandler)
1. HOW TO INCLUDE TRANSLETS IN YOUR APPLICATIONS
---------------------------------------------------------------------
Translets implement the interface com.sun.xslt.Translet
that you will find in the src directory.
public interface Translet {
public void transform(DOM document, TransletOutputHandler handler)
throws TransletException;
public void transform(DOM document, TransletOutputHandler[] handlers)
throws TransletException;
public void transform(DOM document, NodeIterator iterator,
TransletOutputHandler handler) throws
TransletException;
public Object addParameter(String name, Object value);
public void buildKeys(DOM document, NodeIterator iterator,
TransletOutputHandler handler, int root) throws
TransletException;
public String getOutputEncoding();
}
The Translet takes a DOMImpl object (created from an input XML document),
as input and transforms it. The results of the transformation are
sent to an event-based output handler that implements the
com.sun.xslt.TransletOutputHandler interface :
public interface com.sun.xslt.TransletOutputHandler {
public void startDocument() throws TransletException;
public void endDocument() throws TransletException;
public void characters(char[] characters, int offset, int length)
throws TransletException;
public void startElement(String elementName) throws TransletException;
public void endElement(String elementName) throws TransletException;
public void attribute(String attributeName, String attributeValue)
throws TransletException;
public void comment(String comment) throws TransletException;
public void processingInstruction(String target, String data)
throws TransletException;
public void setType(int type);
public void setIndent(boolean indent);
public boolean setEscaping(boolean escape) throws TransletException;
public void insertCdataElement(String elementName);
}
You create an instance of the class that implements the Translet interface
using Java reflection:
Class clazz = Class.forName("classname");
Translet translet = (Translet) clazz.newInstance();
where "classname" is the name of the class generated by XSLTC.
In order to execute a transformation, both a document and a SAX-like
handler (TransletOutputHandler) are needed.
A document instance can be created with the aid of SAX-complaint XML parser.
For example, using Sun's parser you would write,
import com.sun.xslt.dom.DOMImpl;
import com.sun.xml.parser.Parser;
import com.sun.xml.parser.Resolver;
// Create new instances of DOM and Parser
DOMImpl dom = new DOMImpl();
Parser parser = new Parser();
// Set a SAX handler to build a DOM tree
parser.setDocumentHandler(dom.getBuilder());
// Parse the document and build a DOM tree
InputSource input = new InputSource(
new FileReader("xmlfile.xml"));
parser.parse(input);
In this example a document is parsed from a file, but it is also
possible to parse a document from a URI by writing,
parser.parse("http://.../xmlfile.xml");
To transform the input XML document, a call is made to the translet's
transform() method. In order to do its work, the transform() method
takes two arguments, (1) the DOMImpl object created from parsing
the input XML document, and (2) an output handler. The output handler
must implement the org.xml.sax.DocumentHandler interface. You
have the option of: (1) writing your own class that implements
DocumentHandler, or (2) using our default class
'com.sun.xslt.runtime.DefaultSAXOutputHandler' instead.
The source code for our DefaultSAXOutputHandler is included
in this package in the com/sun/xslt/runtime directory.
This is a change from the previous releases of
our compiler API. If you wanted to create your own
output handler in previous releases, you would have write a class that
implemented the interface TransletOutputHandler. This change was made
so that users could more easily plug in any SAX compliant output
handler. To plug in the SAX compliant output handler,
(whether it is a user written class or our DefaultSAXOutputHandler)
into the transform() method, it must be wrapped in a
TextOutput object first.
The Translet.transform() method may also take an array of output handlers.
In this case the transformation will be able to select which handler
to send output to by using the extension element <translet:output port="n">
where 'n' is a 0-based index in the array of output handlers.
Lets take a look at the code needed to carry out both of the options
for passing the SAX output handler to the translet's transform() method:
(1) You would write your own output handler that implements
the org.xml.sax.DocumentHandler interface, pass this class
into our com.sun.xslt.runtime.TextOutput class which itself
implements the TransletOutputHandler interface.
(2) You would create an instance of the default SAX output handler,
com.sun.xslt.runtime.DefaultSAXOutputHandler, pass this
instance into our com.sun.xslt.runtime.TextOutput class which
itself implements the TransletOutputHandler interface.
In option (1), we want to use a SAX compliant output handler that we write
ourselves. In this case we create our Handler class, which implements
org.xml.sax.DocumentHandler:
import org.xml.sax.DocumentHandler;
// user supplied SAX Handler:
class Handler implements DocumentHandler {
public void startDocument() throws SAXException {}
public void endDocument() throws SAXException {}
public void characters(char[] characters, int offset, int length)
throws SAXException
{
System.out.println(new String(characters, offset, length));
}
public void startElement(String elementName, AttributeList attrs)
throws SAXException {}
public void endElement(String elementName) throws SAXException {}
public void setDocumentLocator(Locator loc) {}
public void ignorableWhitespace(char[] characters, int offset, int length)
throws SAXException {}
public void processingInstruction(String target, String data)
throws SAXException {}
}
Now before we pass our handler to the transform() method, we wrap it
in a TextOutput object (which implements the TransletOutputHandler
interface for us). Then given the instantiated translet class,
the transform method could be called as:
import com.sun.xslt.runtime.TextOutput;
DOMImpl dom;
...
Handler saxHandler;
TextOutput textOutput;
try {
saxHandler = new Handler();
textOutput = new TextOutput(saxHandler);
translet.transform(dom, textOutput);
} catch (TransletException e){
...
} catch (IOException e){
...
}
By using the TextOutput wrapper class, one can also control the character
encoding. The TextOutput class has an additional constructor that takes
the DocumentHandler and a String that describes the encoding, for example
'textOutput' could have been created as:
textOutput = new TextOutput(saxHandler, "utf-8");
Finally, option (2) is much like option (1) except you do not have
to write your own DocumentHandler. We provide one by default. To use the
default one, instantiate 'com.sun.xslt.runtime.DefaultSAXOutputHandler'
rather than instantiating your own class (such as Handler above):
import com.sun.xslt.runtime.DefaultSAXOutputHandler;
import com.sun.xslt.runtime.TextOutput;
DefaultSAXOutputHandler defhandlr;
try {
defhandlr = new DefaultSAXOutputHandler(System.out, "utf-8");
translet.transform(dom, new TextOutput(defhandlr));
} catch (TransletException e){
...
} catch (IOException e){
...
}
For a quick reference to the TextOutput and DefaultSAXOutputHandler
constructors available, see the Appendix.
In the following sections, full code examples are shown.
Finally, if you want the transformation results in the DOM form:
DOM result = new DOM();
translet.transform(dom, result.getOutputDomBuilder());
If the compiled stylesheet requires the values of global
parameters to be set, you should call addParameter() before
calling the transform() method.
2. FULL CODE EXAMPLE 1, XsltApp.java, uses a SAX DocumentHandler.
This example corresponds to option (1) in discussion above.
------------------------------------------------------------------
import java.io.FileReader;
import java.io.IOException;
import com.sun.xslt.dom.DOMImpl;
import com.sun.xslt.runtime.TextOutput;
import com.sun.xslt.Translet;
import com.sun.xslt.TransletException;
import com.sun.xml.parser.Parser;
import org.xml.sax.AttributeList;
import org.xml.sax.DocumentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
// Create a SAX Output Handler
class Handler implements DocumentHandler {
public void startDocument() throws SAXException {}
public void endDocument() throws SAXException {}
public void characters(char[] characters, int offset, int length)
throws SAXException
{
System.out.println(new String(characters, offset, length));
}
public void startElement(String elementName, AttributeList attrs)
throws SAXException {}
public void endElement(String elementName) throws SAXException {}
public void setDocumentLocator(Locator loc) {}
public void ignorableWhitespace(char[] characters, int offset, int length)
throws SAXException {}
public void processingInstruction(String target, String data)
throws SAXException {}
}
public class XsltApp {
public static void main(String[] args){
XsltApp app = new XsltApp();
app.run(args);
}
public void run(String[] args){
if(args.length != 2){
usage();
}
String inputFileName = args[0];
String transletName = args[1];
DOMImpl dom = new DOMImpl();
Parser parser = new Parser();
parser.setDocumentHandler(dom.getBuilder());
InputSource input = null;
try {
input = new InputSource(new FileReader(inputFileName));
} catch( java.io.FileNotFoundException e){
System.err.println("File " + inputFileName + " not found");
System.exit(1);
}
try {
parser.parse(input);
} catch (org.xml.sax.SAXException e){
System.err.println("Error: " + e);
System.exit(1);
} catch (IOException e){
System.err.println("Error: " + e);
System.exit(1);
}
Class transletPluggable = null;
try {
transletPluggable = Class.forName(transletName);
} catch (java.lang.ClassNotFoundException e){
System.err.println("Error: " + e);
System.exit(1);
}
Translet translet = null;
try {
translet = (Translet)transletPluggable.newInstance();
} catch (java.lang.Exception e){
System.err.println("Error instantiating pluggable translet");
System.exit(1);
}
Handler saxHandler;
TextOutput textOutput;
try {
saxHandler = new Handler();
textOutput = new TextOutput(saxHandler, "utf-8");
translet.transform(dom, textOutput);
} catch (TransletException e){
System.err.println("Error: " + e);
System.exit(1);
} catch (IOException e){
System.err.println("Error: " + e);
System.exit(1);
}
}
public void usage(){
System.out.println("Usage: \n" +
" xsltapp <xml_file> <translet_name>\n\n" +
" where <file> is xml source (e.g. play.xml). \n" +
" and <translet_name> is java class (e.g. play1). \n"
);
System.exit(1);
}
}
3. COMPILING AND RUNNING THE EXAMPLE:
---------------------------------------------------------------------
To compile the example above, assuming you unpacked the code
into the directory /tmp:
javac -classpath "/tmp/xsltc/lib/xml.jar:/tmp/xsltc/lib/BCEL.jar:/tmp/xsltc
/lib/xsltcrt.jar" XsltApp.java
To run the example on xml document 'play.xml' and stylesheet 'play1.xsl':
(1) compile the stylesheet:
xsltc play1.xsl
this will produce the translet 'play1.class'.
(2) run the translet with the XsltApp demo:
java -classpath /tmp/xsltc/lib/xsltcrt.jar:/tmp/xsltc/lib/xml.jar:. XsltApp play
.xml play1
4. FULL CODE EXAMPLE 2, DefaultRun.java
This example corresponds to option (2) in the discussion above.
------------------------------------------------------------------
See the source file for the class 'com.sun.xslt.runtime.DefaultRun',
which is included in the src directory. It uses the
'DefaultSAXOutputHandler' approach.
5. APPENDIX
------------------------------------------------------------------
TextOutput
----------
package com.sun.xslt.runtime;
public final class TextOutput implements TransletOutputHandler {
public TextOutput(DocumentHandler handler) throws IOException;
public TextOutput(DocumentHandler handler, String encoding) throws
IOException;
}
DefaultSAXOutputHandler
-----------------------
package com.sun.xslt.runtime;
public class DefaultSAXOutputHandler implements DocumentHandler{
public DefaultSAXOutputHandler(Writer writer) throws IOException;
public DefaultSAXOutputHandler(OutputStream out, String encoding)
throws IOException;
public DefaultSAXOutputHandler(String filename, String encoding)
throws IOException;
...
}
------------------------------------------------------------
END OF README
1.1 xml-xalan/java/xdocs/sources/xsltc/README.xslt
Index: README.xslt
===================================================================
NAME
xslt - Sun XSLT runtime processor.
SYNOPSIS
xslt [-j <jarfile>] {-u <document_url> | <document>} <class>
[<name1>=<value1> ...]
DESCRIPTION
The Sun XSLT runtime processor is a Java-based tool for
transforming XML document files using a translet (compiled
stylesheet).
The XSLT processor can be run on any platform including UNIX,
Windows, NT, Mac that supports Java, including a Palm Pilot
with J2ME CLDC (Java 2 Micro Edition, Connected Limited Device
Configuration).
OPTIONS
The following options are supported:
-j <jarfile>
gets the translet <class> from the specified <jarfile>
instead of from the user's CLASSPATH.
-u
Specifies that the XML <document> location will be a URI
such as 'http://myserver/hamlet.xml'.
OPERANDS
The following operands are supported:
<document> An XML document to be processed.
<document_url> An XML document to be processed, specified
as a URL (See -u option above).
<class> The translet that will do the processing.
The translet may optionally take a set of
global parameters specified as name-value
pairs. A name-value pair uses the format
<name>=<value>.
EXAMPLES
Example 1: Processing an XML document.
example% xslt hamlet.xml hamlet
where the current working directory contains an XML document
'hamlet.xml' to be processed by the translet class 'hamlet'.
The translet would have been created initially using
xsltc to compile a XSLT stylesheet named 'hamlet.xsl'.
Example 2: Loading translet from a jar file.
example% xslt -j hamlet.jar hamlet.xml hamlet
In this case the translet class 'hamlet' is loaded from the
specified jar file, 'hamlet.jar' instead of from the user's
CLASSPATH.
Example 3: If the translet defined global parameters, then
these can be passed on the command line to the runtime processor
as a space separated list of name-value pairs using the format
<name>=<value>. For example,
example% xslt hamlet.xml hamlet speaker=HAMLET 'scene=SCENE IV'
Notice that the second name-value pair had to be quoted due to
the intervening space in the value "SCENE IV".
example% xslt -u http://zarya.east/test.xml hamlet
where the xml document 'test.xml' can be specified as a URL.
FILES
file.xml input XML document to be processed.
file.class byte code file.
file.jar java archive file.
SEE ALSO
xsltc, jar.
BUGS
Refer to the top-level README included in this release.
AUTHORS
Jacek Ambroziak, jacek.ambroziak@East.Sun.COM
Santiago Pericas-Geertsen, santiago.pericasgeertsen@East.Sun.COM
Contributors:
Morten Jorgensen morten.jorgensen@Ireland.Sun.COM
G. Todd Miller, todd.miller@East.Sun.COM
1.1 xml-xalan/java/xdocs/sources/xsltc/README.xsltc
Index: README.xsltc
===================================================================
NAME
xsltc - Sun XSLT Compiler
SYNOPSIS
xsltc [-o <output>] [-d <directory>] [-j <jarfile>]
[-p <package name>]
[-u] <stylesheet>...
DESCRIPTION
The Sun XSLT Compiler is a Java-based tool for compiling XSLT
stylesheets into lightweight and portable Java byte codes
called translets.
The XSLT Compiler can be run on any platform including UNIX,
Windows, NT, Mac that supports Java 1.2.x or later. The generated
translets can be run on any platform that supports a Java
Runtime Environment, including a Palm Pilot with J2ME CLDC
(Java 2 Micro Edition, Connected Limited Device Configuration).
OPTIONS
The following options are supported:
-o <output>
Changes the name of the generated translet class.
By default, the translet class would be named
<stylesheet>, if -o <output> is set, then the
translet class would be named <output>. Translet
class files are written as .class files.
-d <directory>
Changes the destination directory. By default, any
translet class files generated would be placed in
the current working directory. If -d <directory>
is specified, the files would be output to <directory>.
-j <jarfile>
Outputs all generated translet class files into a
jar file named <jarfile>.jar. When this option is
used only a jar file will be output.
-p <package name>
Specify a package name for all generated translet
classes.
-u
Specifies that <stylesheet> location will be a URI
such as 'http://myserver/stylesheet1.xsl'.
OPERANDS
The following operand is supported:
<stylesheet> A path name of an input stylesheet file.
EXAMPLES
Example 1: Creating a translet from stylesheet 'hamlet.xsl'.
example% xsltc hamlet.xsl
would produce a set of class files such as 'hamlet.class',
'hamlet$0.class', 'hamlet$1.class'.
Example 2: Outputting all classes into a jar file.
example% xsltc -j hamlet.jar hamlet.xsl
would produce a single jar file output, 'hamlet.jar' which would
contain all the generated .class files for the hamlet translet.
Example 3: Naming the class file.
example% xsltc -o newhamlet hamlet.xsl
would produce a set of class files such as 'newhamlet.class',
'newhamlet$0.class', etc rather than the default which would
be 'hamlet.class', 'hamlet$0.class', etc.
Example 4: Multiple stylesheets.
example% xsltc hamlet1.xsl hamlet2.xsl hamlet3.xsl
would produce a set of class files derived from the three
stylesheets.
Example 5: Package Specification.
example% xsltc -p com.mycompany.translets hamlet.xsl
would produce a set of class files such as
'com/mycompany/translets/hamlet.class',
'com/mycompany/translets/hamlet$0.class', etc.
FILES
file.xsl input XSLT stylesheet
file.class byte code file
file.jar java archive file
SEE ALSO
xslt, jar.
BUGS
Refer to the top-level README included in this release.
AUTHORS
Jacek Ambroziak, jacek.ambroziak@East.Sun.COM
Santiago Pericas-Geertsen, santiago.pericasgeertsen@East.Sun.COM
Contributors:
Morten Jorgensen morten.jorgensen@Ireland.Sun.COM
G. Todd Miller, todd.miller@East.Sun.COM
1.1 xml-xalan/java/xdocs/sources/xsltc/README2
Index: README2
===================================================================
README.APACHE
=====================================================================
Entire source tree and support packages are located in the single jar
file 'apache.jar'.
Installation
-------------
(1) create directory [Root], unpack 'apache.jar' there.
ex) % cd /tmp; mkdir xsltc_apache
% cd xsltc_apache
copy apache.jar to xsltc_apache directory
% jar xvf apache.jar
cleanup
% rm -rf META-INF apache.jar
Unpacking the jar file will result in the following tree:
[Root]
External/
BCEL/ ... contains BCEL.jar
JLex/ ... contains JLex.jar
java_cup/ ... contains java_cup.jar, runtime/runtime.jar
xml-tr2/ ... contains xml.jar
bin/
xslt
xsltc
doc/
api/ ... contains javadoc for api
src/
GNUmakefile
GNUmakefile.allinc
docs/
LICENSE.txt
Message.txt
README
README.api
README.xslt
README.xsltc
XSLTCprn_lg.txt*
xsltcA3.txt
org/
apache/
xalan/
xsltc/
(src tree) ... all the source code files
The 'src tree' is a hierarchy of the following packages:
org.apache.xalan.xsltc
org.apache.xalan.xsltc.compiler
org.apache.xalan.xsltc.compiler.util
org.apache.xalan.xsltc.dom
org.apache.xalan.xsltc.runtime
org.apache.xalan.xsltc.util
org.apache.xalan.xsltc.util.getopt
(2) make bin programs executable
% chmod +x bin/*
(3) set env variable to point to top of directory [Root]
ex) % setenv XSLT /tmp/xsltc_apache
(4) compile sources (uses gnu make and the provides 'GNUmakefile'). This
will create java classes in [Root]/classes, e.g. /tmp/xsltc_apache/classes.
(No need to set your CLASSPATH variable.)
ex) % cd src; gmake again
Note: the 'again' target forces everything to be built from scratch,
including the java_cup source files. Subsequent builds can be done
using the 'classes' target.
(5) make the javadoc
ex) % gmake jdoc
(6) add bin directory to your executable path,
ex) % set path=($XSLT/bin $path)
(7) test distribution, given a stylesheet (test.xsl) and an input xml doc
(test.xml), and be sure current working directory (.) is in your
CLASSPATH.
% xsltc test.xsl ... creates translet, test.class
% xslt test.xml test ... runs translet on xml input
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org