1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.tools;
16  
17  import java.io.FileOutputStream;
18  
19  import javax.xml.transform.Transformer;
20  import javax.xml.transform.TransformerFactory;
21  import javax.xml.transform.stream.StreamResult;
22  import javax.xml.transform.stream.StreamSource;
23  
24  /**
25   * <a href="XSLTBuilder.java.html"><b><i>View Source</i></b></a>
26   *
27   * @author Brian Wing Shun Chan
28   */
29  public class XSLTBuilder {
30  
31      public static void main(String[] args) {
32          if (args.length == 3) {
33              new XSLTBuilder(args[0], args[1], args[2]);
34          }
35          else {
36              throw new IllegalArgumentException();
37          }
38      }
39  
40      public XSLTBuilder(String xml, String xsl, String html) {
41          try {
42              TransformerFactory transformerFactory =
43                  TransformerFactory.newInstance();
44  
45              Transformer transformer = transformerFactory.newTransformer(
46                  new StreamSource(xsl));
47  
48              transformer.transform(
49                  new StreamSource(xml),
50                  new StreamResult(new FileOutputStream(html)));
51          }
52          catch (Exception e) {
53              e.printStackTrace();
54          }
55      }
56  
57  }