// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;

import org.jdom.Document;
import org.jdom.input.SAXBuilder;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
import org.jdom.transform.JDOMResult;
import org.jdom.transform.JDOMSource;

public class SimpleXalan {
    public static void main(String[] args) throws Exception {
        SAXBuilder builder = new SAXBuilder();
        Document xsltdoc = builder.build("C:/message.xsl");
        Document inputDoc = builder.build("C:/message.xml");
        JDOMResult jdomResult = new JDOMResult();
        Transformer obj = TransformerFactory.newInstance().newTransformer(new JDOMSource(xsltdoc));
        obj.transform(new JDOMSource(inputDoc), jdomResult);
        Document resultDoc = jdomResult.getDocument();
        XMLOutputter fmt = new XMLOutputter(Format.getPrettyFormat());
        System.out.println(fmt.outputString(resultDoc));
    }
}
