Initial Commit
[packages] / xemacs-packages / xslt-process / java / xslt / Cocoon1.java
1 /*
2     Cocoon1.java
3
4     Wrapper for the Cocoon XML publishing framework to be invoked in
5     the command line.
6
7     Author: Ovidiu Predescu <ovidiu@cup.hp.com>
8     Date: December 8, 2000
9
10     Copyright (C) 2000 Ovidiu Predescu
11
12     This program is free software; you can redistribute it and/or
13     modify it under the terms of the GNU General Public License as
14     published by the Free Software Foundation; either version 2 of the
15     License, or (at your option) any later version.
16
17     This program is distributed in the hope that it will be useful,
18     but WITHOUT ANY WARRANTY; without even the implied warranty of
19     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20     General Public License for more details.
21
22     You should have received a copy of the GNU General Public License
23     along with this program; if not, write to the Free Software
24     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25     02111-1307, USA.
26  */
27
28 package xslt;
29
30 import org.apache.cocoon.Cocoon;
31
32 public class Cocoon1 
33 {
34   public static String propFilename = null;
35   public static String userAgent = null;
36
37   public static void setPropertyFilename(String filename)
38   {
39     propFilename = filename;
40   }
41
42   public static void setUserAgent(String ua)
43   {
44     userAgent = ua;
45   }
46   
47   public static void invoke(String filename, String outFilename)
48   {
49     if (propFilename == null || propFilename.equals("")) {
50       System.out.println("Please setup the Cocoon properties file in the "
51                          + "customization menu");
52       return;
53     }
54
55     boolean hasUserAgent = userAgent != null && !userAgent.equals("");
56     String[] args = new String[hasUserAgent ? 6 : 4];
57     int i = 0;
58
59     args[i++] = "-p";
60     args[i++] = propFilename;
61     if (hasUserAgent) {
62       args[i++] = "-A";
63       args[i++] = userAgent;
64     }
65     args[i++] =  filename;
66     args[i++] = outFilename;
67
68     try {
69       Cocoon.main(args);
70     }
71     catch (Exception e) {
72       System.out.println("Cannot process: " + e);
73       e.printStackTrace();
74     }
75   }
76 }
77
78 // Local Variables:
79 // c-basic-offset: 2
80 // End: