-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleTransformer.java
More file actions
38 lines (34 loc) · 1.15 KB
/
SimpleTransformer.java
File metadata and controls
38 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java.io.File;
import javax.xml.transform.Source;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
//import javax.xml.transform.*;
public class SimpleTransformer {
public static void main(String[] args) {
SimpleTransformer xslTransformer = new SimpleTransformer();
xslTransformer.transform();
}
public void transform() {
try {
TransformerFactory tFactory =
TransformerFactory.newInstance();
Source stylesheet =
//new StreamSource(new File("layout.xsl"));
new StreamSource(new File("layout_pres.xsl"));
Transformer transformer =
tFactory.newTransformer(stylesheet);
Source inputDoc =
//new StreamSource(new File("searchdata.xml"));
new StreamSource(new File("presidents.xml"));
Result outputDoc =
new StreamResult(new File("search_data_pres.html"));
transformer.transform(inputDoc, outputDoc);
} catch(TransformerException tex) {
tex.printStackTrace();
}
}
}