Interfacing Saxon to Java

The Saxon processor also defines an API for use with Java, but, of course, the details differ from Xalan. Here, I create a new Java class, saxonjava, to show how to create transformations using the Saxon API, version 6.0.2. You start by creating a new XSLT Processorobject by calling the Processorclass’s newInstancemethod in the file saxonjava.java:

import java.io.*; 
import org.xml.sax.*; 
import org.w3c.dom.*; 
import com.icl.saxon.trax.*; 

public class saxonjava 
{

    public static void main(String args[]) 
        throws ProcessorException, ProcessorFactoryException, 
        TransformException, SAXException, IOException 
    {
        Processor processor = Processor.newInstance("xslt"); 
        . 
        . 
        . 

Next, you must create a Templatesobject based on the XSL ...

Get Inside XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.