Java Tutorial/XML/XSLTProcessor
Source for Transformation Application
import org.xml.sax.SAXException;
import org.apache.xalan.xslt.XSLTProcessorFactory;
import org.apache.xalan.xslt.XSLTInputSource;
import org.apache.xalan.xslt.XSLTResultTarget;
import org.apache.xalan.xslt.XSLTProcessor;
import java.io.FileOutputStream;
public class xalantransform {
public static void main(String[] args) throws java.io.IOException,
java.net.MalformedURLException, org.xml.sax.SAXException {
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
processor.process(new XSLTInputSource(args[0]), new XSLTInputSource(args[1]),
new XSLTResultTarget(new FileOutputStream(args[2])));
}
}
Source for Transforming org.w3c.dom.Node
import org.xml.sax.SAXException;
import org.apache.xalan.xslt.XSLTProcessorFactory;
import org.apache.xalan.xslt.XSLTInputSource;
import org.apache.xalan.xslt.XSLTResultTarget;
import org.apache.xalan.xslt.XSLTProcessor;
import org.w3c.dom.Document;
import org.apache.xerces.parsers.DOMParser;
import java.io.FileOutputStream;
public class xalantransformNode {
public static void main(String[] args) throws java.io.IOException,
java.net.MalformedURLException, org.xml.sax.SAXException {
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
DOMParser parser = new DOMParser();
parser.parse(args[0]);
Document dom = parser.getDocument();
processor.process(new XSLTInputSource(dom), new XSLTInputSource(args[1]), new XSLTResultTarget(
new FileOutputStream(args[2])));
}
}