-
Notifications
You must be signed in to change notification settings - Fork 76
/
XsltTransform.java
31 lines (20 loc) · 812 Bytes
/
XsltTransform.java
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
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class XsltTransform {
public static final String XSLT = "suffix-sfm-pom.xslt";
public static void main(String[] args) throws Exception {
String suffix = args[0];
Source xsl = new StreamSource(new File(XSLT));
Transformer transformer = TransformerFactory.newInstance().newTransformer(xsl);
transformer.setParameter("suffix", suffix);
for(int i = 1; i < args.length; i++ ) {
File f = new File(args[i]);
File t = new File(args[i] + "~");
Source xmlInput = new StreamSource(f);
Result xmlOutput = new StreamResult(t);
transformer.transform(xmlInput, xmlOutput);
f.delete(); t.renameTo(f);
}
}
}