|  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 | | |  |  |  | XSLTC's native API is represented by the
    org.apache.xalan.xsltc.compiler.XSLTCclass. Any application
    using XSLTC's native API should only have to access methods in this class
    in order to compile a stylesheet (or a set or stylesheets) into one or
    more Java classes. TheXSLTChas an empty constructor. The
    class needs to be initialized before each compilation by a call to: |  |  |  | There is a set of methods for compiling one or more stylesheets into a
    set of Java classes. The stylesheet can be specified either as a
    URL,InputStream,InputSourceor
    aVectorcontaining a set ofURLs pointing to
    stylesheets: |  |  |  |  |  | 
    public boolean compile(URL url);
    public boolean compile(URL url, String transletName);
    public boolean compile(InputStream stream, String transletName);
    public boolean compile(InputSource input, String transletName);
    public boolean compile(Vector stylesheets); |  |  |  |  |  | 
The default behaviour is to output the compiled Java class(es) to one or
    more Java classes in the current working directory. The name of the main
    translet class will be obtained from (in order of priority): 
      that specified in the compile()methodif none is specified (if the parameter is 'null') the name will be
      generated from the filename specified by the input URL/file/streamthe default translet name (set by setClassName())the built-in default class name "GregorSamsa" Additional Java classes will be generated for complex stylesheets. These
    classes represent elements such as predicates, sort-records, etc. in the
    stylesheet. Additional classes share the same root name as the main translet
    class, with a suffix containing a '$'-sign and a sequence number. The result
    of a single compilation of a complex stylesheet could be: |  |  |  |  |  | 
    GregorSamsa.java
    GregorSamsa$0.java
    GregorSamsa$1.java
    GregorSamsa$2.java
    GregorSamsa$3.java |  |  |  |  |  | 
It is not always desireable having these classes dumped to files in the
    current working directory. There is one compile()method that
    will return the Java class definitions as bytecodes. The bytecodes are
    returned in a two-dimmensionalbytearray. Each byte-array
    contains the bytecodes for one Java class: |  |  |  |  |  | 
    public byte[][] compile(String name, InputSource input); |  |  |  |  |  | 
Alternatively, one can first compile the stylesheet into one or more
    Java class files, and then also retrieve the bytecodes from the compiler: |  |  |  |  |  | 
    public byte[][] getBytecodes(); |  |  |  |  |  | 
 | 
 
 
 
 
 
 | 
 
 |  |  |  | The steps described in this chapter are covered in these sample
    source code files: 
      org.apache.xalan.xsltc.cmdline.Transformxml-xalan/java/samples/CompiledApplet/TransformApplet.javaxml-xalan/java/samples/CompiledBrazil/TransformHandler.javaxml-xalan/java/samples/CompiledEJB/TransformBean.javaxml-xalan/java/samples/CompiledEJB/TransformHome.javaxml-xalan/java/samples/CompiledEJB/TransformRemote.javaxml-xalan/java/samples/CompiledEJB/TransformServlet.javaxml-xalan/java/samples/CompiledServlet/CompileServlet.javaxml-xalan/java/samples/CompiledServlet/TransformServlet.java 
 
 
 
 
 | 
 
 | 
 |