All Java-based XSLT processors define an extensive interfacean APIto connect to Java. Typically, you use the API to create Java objects and call methods , as youll see in this chapter. However, all XSLT processors define their APIs differently, and theyre usually extensive , because each processor is free to create its own class and method hierarchies.
In the following sections, I work through the process of creating XSLT transformations from Java with Xalan, Saxon, XT, and the Oracle XSLT processor.
You should refer to the documentation that comes with these processors to see what other kinds of capabilities are available. Note that the APIs of most of these processors could themselves fill a book, so the discussion of these processors is, of necessity, only an overview.
Naming Java Files
Writing Java files is one instance where the name of the file does matter, unlike the other examples in this book. As discussed in Inside XML , Java insists that the name of a file must match the name of the public class in the file. For that reason, I include the name of the file you should use for each listing in the heading that appears right before the listing. For example, Listing 10.7, xalanjava.java, Interfacing Xalan to Java, means that you should save the code in the listing as xalanjava.java before trying to use it with Java (to make it easier, I use lowercase for all Java public classes and filenames). Note also that if you download the books code, this example is named 10-07.java , and you should rename it to xalanjava.java before using it. I also add the name you should use to store the file in a comment at the beginning of each Java file.