001
014
015 package com.liferay.portal.tools;
016
017 import com.liferay.portal.kernel.util.StringPool;
018
019 import java.io.FileOutputStream;
020
021 import javax.xml.transform.Transformer;
022 import javax.xml.transform.TransformerFactory;
023 import javax.xml.transform.stream.StreamResult;
024 import javax.xml.transform.stream.StreamSource;
025
026
029 public class XSLTBuilder {
030
031 public static void main(String[] args) {
032 if (args.length == 3) {
033 new XSLTBuilder(args[0], args[1], args[2]);
034 }
035 else {
036 throw new IllegalArgumentException();
037 }
038 }
039
040 public XSLTBuilder(String xml, String xsl, String html) {
041 try {
042 System.setProperty("line.separator", StringPool.NEW_LINE);
043
044 TransformerFactory transformerFactory =
045 TransformerFactory.newInstance();
046
047 Transformer transformer = transformerFactory.newTransformer(
048 new StreamSource(xsl));
049
050 transformer.transform(
051 new StreamSource(xml),
052 new StreamResult(new FileOutputStream(html)));
053 }
054 catch (Exception e) {
055 e.printStackTrace();
056 }
057 }
058
059 }