// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
package xmlproc;

import java.io.File;

import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

public class XSLT {
    private final static String XML_FILE = "/work/employees.xml";
    private final static String XSL_FILE = "/work/employees.xsl";
    public static void main(String[] args) throws Exception {
        // transform from one file to another file
        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer t = tf.newTransformer(new StreamSource(new File(XSL_FILE)));
        t.setOutputProperty(OutputKeys.INDENT, "yes");
        t.transform(new StreamSource(new File(XML_FILE)), new StreamResult(new File("/work/employees2.xml")));
    }
}
