import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public class JAXPTransform {
public static void main(String args[]) throws TransformerConfigurationException,
TransformerException, FileNotFoundException {
TransformerFactory factory = TransformerFactory.newInstance();
StreamSource stylesheet = new StreamSource(args[1]);
StreamSource xmlDoc = new StreamSource(args[0]);
StreamResult result = new StreamResult(new FileOutputStream(args[2]));
Transformer transFormer = factory.newTransformer(stylesheet);
transFormer.transform(xmlDoc, result);
}
}
|