XSLTTest.java



import java.io.File;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;

/** XSLT Parse Test */
public class XSLTTest {

  /** Files */
    private File inputFile = null;
    private File transFile = null;
    private File outputFile = null;

  /** Stream Sources, Result */
    private Source inputSource = null;
    private Source transSource = null;
    private Result outputResult = null;

  /** Transformer */
    private Transformer transformer = null;

  /** Constructor */
    public XSLTTest() {
        try {
            inputFile = new File( "sample6.xml" );
            transFile = new File( "doc2html.xsl" );
            outputFile = new File( "sample6.html" );
            inputSource = new StreamSource( inputFile );
            transSource = new StreamSource( transFile );
            outputResult = new StreamResult( outputFile );

            TransformerFactory tf
                = TransformerFactory.newInstance();
                 // System.out.println( tf.toString() );
            transformer = tf.newTransformer( transSource );
                 // System.out.println( transformer.toString() );
            transformer.transform( inputSource, outputResult );
        }
        catch( Exception e ) {
            System.err.println( e.toString() );
        }
    }

  /** main (start here) */
    public static void main( String[] argv ) {
        try {
            XSLTTest test = new XSLTTest();
        }
        catch( Exception e ) {
            System.err.println( e.toString() );
        }
    }
}