P3.java
import java.io.*;
import java.util.*;
import org.xml.sax.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.sax.*;
import javax.xml.transform.stream.*;
/**
Apply an XSLT stylesheet to an XML file to produce HTML.
*/
public class P3
{
public static void main(String[] argv)
{
String input = "tempest.xml";
String output = "tempest.html";
String xsl = "play.xsl";
try {
File styleSheet = new File(xsl);
StreamSource styleSource = new StreamSource(styleSheet);
Transformer t =
TransformerFactory.
newInstance().
newTransformer(styleSource);
t.transform(
new StreamSource(input),
new StreamResult(output));
}
catch (Exception e) {
e.printStackTrace();
}
}
}