Transform2.java Source code

Java tutorial

Introduction

Here is the source code for Transform2.java

Source

import java.io.File;
import java.io.FileWriter;

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

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

public class Transform2 {
    public static void main(String[] args) throws Exception {
        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build(new File("r.xml"));
        Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource("program.xsl"));
        JDOMResult out = new JDOMResult();
        transformer.transform(new JDOMSource(document), out);
        XMLOutputter xmlOutputter = new XMLOutputter();
        xmlOutputter.output(out.getDocument(), new FileWriter("JDOMAlteredRichard.html"));
    }
}