libis-format 1.2.7 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/tools/fop/fop.js CHANGED
@@ -1,341 +1,341 @@
1
- // Licensed to the Apache Software Foundation (ASF) under one or more
2
- // contributor license agreements. See the NOTICE file distributed with
3
- // this work for additional information regarding copyright ownership.
4
- // The ASF licenses this file to You under the Apache License, Version 2.0
5
- // (the "License"); you may not use this file except in compliance with
6
- // the License. You may obtain a copy of the License at
7
- //
8
- // http://www.apache.org/licenses/LICENSE-2.0
9
- //
10
- // Unless required by applicable law or agreed to in writing, software
11
- // distributed under the License is distributed on an "AS IS" BASIS,
12
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- // See the License for the specific language governing permissions and
14
- // limitations under the License.
15
- // $Id: fop.js 1734671 2016-03-12 05:39:53Z gadams $ -->
16
-
17
- // jscript to run FOP, adapted from the Jakarta-Ant project.
18
-
19
- // rpm_mode is irrelevant on Windows
20
- // var rpm_mode=true;
21
- var fop_exec_args = "";
22
- var no_config=false;
23
- var fop_exec_debug=false;
24
- var debug=false;
25
- var keep_open=false;
26
- var show_help=false;
27
-
28
- var config_wanted = new Array("FOP_HOME", "CLASSPATH", "FOP_HYPHENATION_PATH", "FOP_OPTS", "JAVA_OPTS", "LOGCHOICE", "LOGLEVEL");
29
-
30
- // parse command-line arguments
31
- function read_args() {
32
- var args = WScript.Arguments;
33
- var named = new ActiveXObject("Scripting.Dictionary");
34
- for (i = 0; i < args.length; i++) {
35
- switch(args(i)) {
36
- case "--debug":
37
- debug=true;
38
- break;
39
- case "--execdebug":
40
- fop_exec_debug=true;
41
- break;
42
- case "--keepopen":
43
- keep_open=true;
44
- break;
45
- case "--noconfig":
46
- no_config=true;
47
- break;
48
- case "-h":
49
- case "--help":
50
- case "--h":
51
- case "-help":
52
- show_help=true;
53
- // fop_exec_args=fop_exec_args + " -h";
54
- break;
55
- default:
56
- fop_exec_args=fop_exec_args + " " + args(i);
57
- }
58
- }
59
- if (debug) {
60
- WScript.Echo("debug: " + debug);
61
- WScript.Echo("execdebug: " + fop_exec_debug);
62
- WScript.Echo("keepopen: " + keep_open);
63
- WScript.Echo("noconfig: " + no_config);
64
- WScript.Echo("help: " + show_help);
65
- WScript.Echo("fop arguments: " + fop_exec_args);
66
- }
67
- }
68
-
69
- var help_text="Usage:\n"
70
- + WScript.ScriptFullName + " [script options] [FOP options]\n"
71
- + "Script Options:\n"
72
- + " --help, -h print this message and FOP help\n"
73
- + " --debug print debugging information for this launch script\n"
74
- + " --execdebug print FOP exec line generated by this launch script\n"
75
- + " --keepopen keep FOP's command window open\n"
76
- + " --noconfig suppress reading of configuration file and registry";
77
-
78
- function read_environment() {
79
- for (i in config_wanted) {
80
- if (!config.Exists(config_wanted[i])) {
81
- var env_var_string = "%" + config_wanted[i] + "%";
82
- var env_var = shell.ExpandEnvironmentStrings(env_var_string);
83
- if (env_var != "" && env_var != env_var_string) {
84
- config.Add(config_wanted[i], env_var);
85
- if (debug) {
86
- WScript.Echo(config_wanted[i] + " env: "
87
- + config.Item(config_wanted[i]));
88
- }
89
- }
90
- }
91
- }
92
- }
93
-
94
- function read_desktop(dtname) {
95
- if (fs.FolderExists(dtname)) {
96
- var fopname = fs.GetFolder(dtname).ParentFolder.Path
97
- + "\\Application Data\\Fop";
98
- if (fs.FolderExists(fopname)) {
99
- var fop_conf_name = fs.GetFolder(fopname).Path + "\\fop.conf";
100
- if (fs.FileExists(fop_conf_name)) {
101
- // source fop_conf_file
102
- var conf_file = fs.openTextFile(fs.GetFile(fop_conf_name));
103
- var conf_lines = new ActiveXObject("Scripting.Dictionary");
104
- while (!conf_file.AtEndOfStream) {
105
- var line = conf_file.ReadLine();
106
- var m = line.match(/(.+?)=(.+)/);
107
- if (m != null) {
108
- conf_lines.Add(m[1], m[2]);
109
- }
110
- }
111
- for (j in config_wanted) {
112
- if (!config.Exists(config_wanted[j])
113
- && conf_lines.Exists(config_wanted[j])) {
114
- config.Add(config_wanted[j], conf_lines.Item(config_wanted[j]));
115
- if (debug) {
116
- WScript.Echo(config_wanted[j] + " " + dts[i] + ": "
117
- + config.Item(config_wanted[i]));
118
- }
119
- }
120
- }
121
- }
122
- }
123
- }
124
- }
125
-
126
- function read_registry(section) {
127
- for (j in config_wanted) {
128
- if (!config.Exists(config_wanted[j])) {
129
- var reg_var;
130
- try {
131
- reg_var = shell.RegRead(section + "\\Software\\Fop\\"
132
- + config_wanted[j]);
133
- config.Add(config_wanted[j], reg_var);
134
- if (debug) {
135
- WScript.Echo(config_wanted[j] + " " + rks[i] + ": "
136
- + config.Item(config_wanted[j]));
137
- }
138
- } catch(e) {}
139
- }
140
- }
141
- }
142
-
143
- // construct FOP_HOME from the script folder
144
- function get_fop_home() {
145
- if (!config.Exists("FOP_HOME")
146
- || !fs.FolderExists(config.Item("FOP_HOME"))) {
147
- var fop_home = WScript.ScriptFullName;
148
- fop_home = fop_home.substring(0, fop_home.length
149
- - WScript.ScriptName.length - 1);
150
- if (config.Exists("FOP_HOME")) {
151
- config.Remove("FOP_HOME");
152
- }
153
- config.Add("FOP_HOME", fop_home);
154
- if (debug) {
155
- WScript.Echo("FOP_HOME dyn: " + config.Item("FOP_HOME"));
156
- }
157
- }
158
- }
159
-
160
- function get_java_cmd() {
161
- var java_home = shell.ExpandEnvironmentStrings("%JAVA_HOME%");
162
- javacmd = "java";
163
- if (java_home != "" && typeof(java_home) != "undefined"
164
- && fs.FolderExists(java_home)) {
165
- var javacmd_candidate = java_home + "\\bin\\java.exe";
166
- if (fs.FileExists(javacmd_candidate)) {
167
- javacmd = javacmd_candidate;
168
- }
169
- }
170
- if (debug) {
171
- WScript.Echo("java command: " + javacmd);
172
- }
173
- }
174
-
175
- function get_local_classpath() {
176
- if (config.Exists("CLASSPATH")) {
177
- local_classpath = config.Item("CLASSPATH");
178
- if (debug) {
179
- WScript.Echo("local classpath: " + local_classpath);
180
- }
181
- }
182
-
183
- // add fop.jar, fop-sandbox and fop-hyph.jar, which reside in $FOP_HOME/build
184
- var lcp = local_classpath;
185
- local_classpath = config.Item("FOP_HOME") + "\\build\\fop.jar;"
186
- + config.Item("FOP_HOME") + "\\build\\fop-sandbox.jar;"
187
- + config.Item("FOP_HOME") + "\\build\\fop-hyph.jar";
188
- if (lcp != "") {
189
- local_classpath += ";" + lcp;
190
- }
191
- if (debug) {
192
- WScript.Echo("local classpath: " + local_classpath);
193
- }
194
-
195
- // add in the dependency .jar files, which reside in $FOP_HOME/lib
196
- var libdir_name = config.Item("FOP_HOME") + "\\lib";
197
- var dirlibs;
198
- if (fs.FolderExists(libdir_name)) {
199
- dirlibs = fs.GetFolder(libdir_name).Files;
200
- var e = new Enumerator(dirlibs);
201
- for (; !e.atEnd(); e.moveNext()) {
202
- if (e.item().Name.match("\.jar$")) {
203
- local_classpath = libdir_name + "\\" + e.item().Name + ";" + local_classpath;
204
- }
205
- }
206
- if (debug) {
207
- WScript.Echo("local classpath: " + local_classpath);
208
- }
209
- }
210
-
211
- // add in user-defined hyphenation JARs
212
- if (config.Exists("FOP_HYPHENATION_PATH")) {
213
- local_classpath += ";" + config.Item("FOP_HYPHENATION_PATH");
214
- if (debug) {
215
- WScript.Echo("local classpath: " + local_classpath);
216
- }
217
- }
218
- }
219
-
220
- // Execute fop via shell.Exec
221
- function fop_exec() {
222
- var fop_exec_command = "\"" + javacmd + "\" "
223
- + (config.Exists("JAVA_OPTS")?config.Item("JAVA_OPTS") + " ":"")
224
- + (config.Exists("LOGCHOICE")?config.Item("LOGCHOICE") + " ":"")
225
- + (config.Exists("LOGLEVEL")?config.Item("LOGLEVEL") + " ":"")
226
- + "-classpath \"" + local_classpath + "\" "
227
- + (config.Exists("FOP_OPTS")?config.Item("FOP_OPTS"):"")
228
- + "org.apache.fop.cli.Main " + fop_exec_args;
229
- if (debug || fop_exec_debug) {
230
- WScript.Echo(fop_exec_command);
231
- }
232
-
233
- var fop_run = shell.Exec(fop_exec_command);
234
- while (true) {
235
- while (!fop_run.StdOut.AtEndOfStream) {
236
- WScript.Echo(fop_run.StdOut.ReadLine());
237
- }
238
- while (!fop_run.StdErr.AtEndOfStream) {
239
- WScript.Echo(fop_run.StdErr.ReadLine());
240
- }
241
- if (fop_run.Status == 1) {
242
- break;
243
- }
244
- WScript.Sleep(100);
245
- }
246
- if (debug) {
247
- WScript.Echo("exit status: " + fop_run.ExitCode);
248
- }
249
- }
250
-
251
- // Execute fop via shell.Run
252
- function fop_run() {
253
- var fop_exec_command = "cmd /" + (keep_open?"K":"C") + " \""
254
- + "\"" + javacmd + "\" "
255
- + (config.Exists("JAVA_OPTS")?config.Item("JAVA_OPTS") + " ":"")
256
- + (config.Exists("LOGCHOICE")?config.Item("LOGCHOICE") + " ":"")
257
- + (config.Exists("LOGLEVEL")?config.Item("LOGLEVEL") + " ":"")
258
- + "-classpath \"" + local_classpath + "\" "
259
- + (config.Exists("FOP_OPTS")?config.Item("FOP_OPTS") + " ":"")
260
- + "org.apache.fop.cli.Main " + fop_exec_args + "\"";
261
- if (debug || fop_exec_debug) {
262
- WScript.Echo(fop_exec_command);
263
- }
264
- var exit_code = shell.Run(fop_exec_command, 1, 1);
265
- if (debug) {
266
- WScript.Echo("exit status: " + exit_code);
267
- } else {
268
- if (exit_code != 0) {
269
- WScript.Echo("A FOP error occurred (FOP exit status: " + exit_code + ")\n"
270
- + "Use option --keepopen to see FOP's output\n"
271
- + "(that is two dashes)");
272
- }
273
- }
274
- }
275
-
276
- function get_log_choice() {
277
- // The default commons logger for JDK1.4 is JDK1.4Logger.
278
- // To use a different logger, uncomment the one desired below
279
- if (!config.Exists("LOGCHOICE")) {
280
- // config.Add("LOGCHOICE","\"-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog\"");
281
- // config.Add("LOGCHOICE","\"-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog\"");
282
- // config.Add("LOGCHOICE","\"-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger\"");
283
- if (debug && config.Exists("LOGCHOICE")) {
284
- WScript.Echo("LOGCHOICE script: " + config.Item("LOGCHOICE"));
285
- }
286
- }
287
- }
288
-
289
- function get_log_level() {
290
- // Logging levels
291
- // Below option is only if you are using SimpleLog instead of the default JDK1.4 Logger.
292
- // To set logging levels for JDK 1.4 Logger, edit the %JAVA_HOME%/JRE/LIB/logging.properties
293
- // file instead.
294
- // Possible SimpleLog values: "trace", "debug", "info" (default), "warn", "error", or "fatal".
295
- if (!config.Exists("LOGLEVEL")) {
296
- // config.Add("LOGLEVEL","\"-Dorg.apache.commons.logging.simplelog.defaultlog=INFO\"");
297
- if (debug && config.Exists("LOGLEVEL")) {
298
- WScript.Echo("LOGLEVEL script: " + config.Item("LOGLEVEL"));
299
- }
300
- }
301
- }
302
-
303
- var shell = WScript.CreateObject("WScript.Shell");
304
- var fs = WScript.CreateObject("Scripting.FileSystemObject");
305
-
306
- // configuration
307
- var config = new ActiveXObject("Scripting.Dictionary");
308
-
309
- read_args();
310
- read_environment();
311
- if (!no_config) {
312
- // read user and system-wide fop configurations
313
- var spec = shell.SpecialFolders;
314
- var dts = new Array("Desktop", "AllUsersDesktop");
315
- for (i in dts) {
316
- read_desktop(spec(dts[i]));
317
- }
318
- // read user and system-wide registry
319
- var rks = new Array("HKCU", "HKLM");
320
- for (i in rks) {
321
- read_registry(rks[i]);
322
- }
323
- }
324
-
325
- get_fop_home();
326
- get_log_choice();
327
- get_log_level();
328
- var javacmd = "";
329
- get_java_cmd();
330
- var local_classpath = "";
331
- get_local_classpath();
332
-
333
- // Show script help if requested
334
- if (show_help) {
335
- // fop_exec_args = "";
336
- keep_open = true;
337
- WScript.Echo(help_text);
338
- }
339
-
340
- // fop_exec();
341
- fop_run();
1
+ // Licensed to the Apache Software Foundation (ASF) under one or more
2
+ // contributor license agreements. See the NOTICE file distributed with
3
+ // this work for additional information regarding copyright ownership.
4
+ // The ASF licenses this file to You under the Apache License, Version 2.0
5
+ // (the "License"); you may not use this file except in compliance with
6
+ // the License. You may obtain a copy of the License at
7
+ //
8
+ // http://www.apache.org/licenses/LICENSE-2.0
9
+ //
10
+ // Unless required by applicable law or agreed to in writing, software
11
+ // distributed under the License is distributed on an "AS IS" BASIS,
12
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ // See the License for the specific language governing permissions and
14
+ // limitations under the License.
15
+ // $Id: fop.js 1734671 2016-03-12 05:39:53Z gadams $ -->
16
+
17
+ // jscript to run FOP, adapted from the Jakarta-Ant project.
18
+
19
+ // rpm_mode is irrelevant on Windows
20
+ // var rpm_mode=true;
21
+ var fop_exec_args = "";
22
+ var no_config=false;
23
+ var fop_exec_debug=false;
24
+ var debug=false;
25
+ var keep_open=false;
26
+ var show_help=false;
27
+
28
+ var config_wanted = new Array("FOP_HOME", "CLASSPATH", "FOP_HYPHENATION_PATH", "FOP_OPTS", "JAVA_OPTS", "LOGCHOICE", "LOGLEVEL");
29
+
30
+ // parse command-line arguments
31
+ function read_args() {
32
+ var args = WScript.Arguments;
33
+ var named = new ActiveXObject("Scripting.Dictionary");
34
+ for (i = 0; i < args.length; i++) {
35
+ switch(args(i)) {
36
+ case "--debug":
37
+ debug=true;
38
+ break;
39
+ case "--execdebug":
40
+ fop_exec_debug=true;
41
+ break;
42
+ case "--keepopen":
43
+ keep_open=true;
44
+ break;
45
+ case "--noconfig":
46
+ no_config=true;
47
+ break;
48
+ case "-h":
49
+ case "--help":
50
+ case "--h":
51
+ case "-help":
52
+ show_help=true;
53
+ // fop_exec_args=fop_exec_args + " -h";
54
+ break;
55
+ default:
56
+ fop_exec_args=fop_exec_args + " " + args(i);
57
+ }
58
+ }
59
+ if (debug) {
60
+ WScript.Echo("debug: " + debug);
61
+ WScript.Echo("execdebug: " + fop_exec_debug);
62
+ WScript.Echo("keepopen: " + keep_open);
63
+ WScript.Echo("noconfig: " + no_config);
64
+ WScript.Echo("help: " + show_help);
65
+ WScript.Echo("fop arguments: " + fop_exec_args);
66
+ }
67
+ }
68
+
69
+ var help_text="Usage:\n"
70
+ + WScript.ScriptFullName + " [script options] [FOP options]\n"
71
+ + "Script Options:\n"
72
+ + " --help, -h print this message and FOP help\n"
73
+ + " --debug print debugging information for this launch script\n"
74
+ + " --execdebug print FOP exec line generated by this launch script\n"
75
+ + " --keepopen keep FOP's command window open\n"
76
+ + " --noconfig suppress reading of configuration file and registry";
77
+
78
+ function read_environment() {
79
+ for (i in config_wanted) {
80
+ if (!config.Exists(config_wanted[i])) {
81
+ var env_var_string = "%" + config_wanted[i] + "%";
82
+ var env_var = shell.ExpandEnvironmentStrings(env_var_string);
83
+ if (env_var != "" && env_var != env_var_string) {
84
+ config.Add(config_wanted[i], env_var);
85
+ if (debug) {
86
+ WScript.Echo(config_wanted[i] + " env: "
87
+ + config.Item(config_wanted[i]));
88
+ }
89
+ }
90
+ }
91
+ }
92
+ }
93
+
94
+ function read_desktop(dtname) {
95
+ if (fs.FolderExists(dtname)) {
96
+ var fopname = fs.GetFolder(dtname).ParentFolder.Path
97
+ + "\\Application Data\\Fop";
98
+ if (fs.FolderExists(fopname)) {
99
+ var fop_conf_name = fs.GetFolder(fopname).Path + "\\fop.conf";
100
+ if (fs.FileExists(fop_conf_name)) {
101
+ // source fop_conf_file
102
+ var conf_file = fs.openTextFile(fs.GetFile(fop_conf_name));
103
+ var conf_lines = new ActiveXObject("Scripting.Dictionary");
104
+ while (!conf_file.AtEndOfStream) {
105
+ var line = conf_file.ReadLine();
106
+ var m = line.match(/(.+?)=(.+)/);
107
+ if (m != null) {
108
+ conf_lines.Add(m[1], m[2]);
109
+ }
110
+ }
111
+ for (j in config_wanted) {
112
+ if (!config.Exists(config_wanted[j])
113
+ && conf_lines.Exists(config_wanted[j])) {
114
+ config.Add(config_wanted[j], conf_lines.Item(config_wanted[j]));
115
+ if (debug) {
116
+ WScript.Echo(config_wanted[j] + " " + dts[i] + ": "
117
+ + config.Item(config_wanted[i]));
118
+ }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ }
124
+ }
125
+
126
+ function read_registry(section) {
127
+ for (j in config_wanted) {
128
+ if (!config.Exists(config_wanted[j])) {
129
+ var reg_var;
130
+ try {
131
+ reg_var = shell.RegRead(section + "\\Software\\Fop\\"
132
+ + config_wanted[j]);
133
+ config.Add(config_wanted[j], reg_var);
134
+ if (debug) {
135
+ WScript.Echo(config_wanted[j] + " " + rks[i] + ": "
136
+ + config.Item(config_wanted[j]));
137
+ }
138
+ } catch(e) {}
139
+ }
140
+ }
141
+ }
142
+
143
+ // construct FOP_HOME from the script folder
144
+ function get_fop_home() {
145
+ if (!config.Exists("FOP_HOME")
146
+ || !fs.FolderExists(config.Item("FOP_HOME"))) {
147
+ var fop_home = WScript.ScriptFullName;
148
+ fop_home = fop_home.substring(0, fop_home.length
149
+ - WScript.ScriptName.length - 1);
150
+ if (config.Exists("FOP_HOME")) {
151
+ config.Remove("FOP_HOME");
152
+ }
153
+ config.Add("FOP_HOME", fop_home);
154
+ if (debug) {
155
+ WScript.Echo("FOP_HOME dyn: " + config.Item("FOP_HOME"));
156
+ }
157
+ }
158
+ }
159
+
160
+ function get_java_cmd() {
161
+ var java_home = shell.ExpandEnvironmentStrings("%JAVA_HOME%");
162
+ javacmd = "java";
163
+ if (java_home != "" && typeof(java_home) != "undefined"
164
+ && fs.FolderExists(java_home)) {
165
+ var javacmd_candidate = java_home + "\\bin\\java.exe";
166
+ if (fs.FileExists(javacmd_candidate)) {
167
+ javacmd = javacmd_candidate;
168
+ }
169
+ }
170
+ if (debug) {
171
+ WScript.Echo("java command: " + javacmd);
172
+ }
173
+ }
174
+
175
+ function get_local_classpath() {
176
+ if (config.Exists("CLASSPATH")) {
177
+ local_classpath = config.Item("CLASSPATH");
178
+ if (debug) {
179
+ WScript.Echo("local classpath: " + local_classpath);
180
+ }
181
+ }
182
+
183
+ // add fop.jar, fop-sandbox and fop-hyph.jar, which reside in $FOP_HOME/build
184
+ var lcp = local_classpath;
185
+ local_classpath = config.Item("FOP_HOME") + "\\build\\fop.jar;"
186
+ + config.Item("FOP_HOME") + "\\build\\fop-sandbox.jar;"
187
+ + config.Item("FOP_HOME") + "\\build\\fop-hyph.jar";
188
+ if (lcp != "") {
189
+ local_classpath += ";" + lcp;
190
+ }
191
+ if (debug) {
192
+ WScript.Echo("local classpath: " + local_classpath);
193
+ }
194
+
195
+ // add in the dependency .jar files, which reside in $FOP_HOME/lib
196
+ var libdir_name = config.Item("FOP_HOME") + "\\lib";
197
+ var dirlibs;
198
+ if (fs.FolderExists(libdir_name)) {
199
+ dirlibs = fs.GetFolder(libdir_name).Files;
200
+ var e = new Enumerator(dirlibs);
201
+ for (; !e.atEnd(); e.moveNext()) {
202
+ if (e.item().Name.match("\.jar$")) {
203
+ local_classpath = libdir_name + "\\" + e.item().Name + ";" + local_classpath;
204
+ }
205
+ }
206
+ if (debug) {
207
+ WScript.Echo("local classpath: " + local_classpath);
208
+ }
209
+ }
210
+
211
+ // add in user-defined hyphenation JARs
212
+ if (config.Exists("FOP_HYPHENATION_PATH")) {
213
+ local_classpath += ";" + config.Item("FOP_HYPHENATION_PATH");
214
+ if (debug) {
215
+ WScript.Echo("local classpath: " + local_classpath);
216
+ }
217
+ }
218
+ }
219
+
220
+ // Execute fop via shell.Exec
221
+ function fop_exec() {
222
+ var fop_exec_command = "\"" + javacmd + "\" "
223
+ + (config.Exists("JAVA_OPTS")?config.Item("JAVA_OPTS") + " ":"")
224
+ + (config.Exists("LOGCHOICE")?config.Item("LOGCHOICE") + " ":"")
225
+ + (config.Exists("LOGLEVEL")?config.Item("LOGLEVEL") + " ":"")
226
+ + "-classpath \"" + local_classpath + "\" "
227
+ + (config.Exists("FOP_OPTS")?config.Item("FOP_OPTS"):"")
228
+ + "org.apache.fop.cli.Main " + fop_exec_args;
229
+ if (debug || fop_exec_debug) {
230
+ WScript.Echo(fop_exec_command);
231
+ }
232
+
233
+ var fop_run = shell.Exec(fop_exec_command);
234
+ while (true) {
235
+ while (!fop_run.StdOut.AtEndOfStream) {
236
+ WScript.Echo(fop_run.StdOut.ReadLine());
237
+ }
238
+ while (!fop_run.StdErr.AtEndOfStream) {
239
+ WScript.Echo(fop_run.StdErr.ReadLine());
240
+ }
241
+ if (fop_run.Status == 1) {
242
+ break;
243
+ }
244
+ WScript.Sleep(100);
245
+ }
246
+ if (debug) {
247
+ WScript.Echo("exit status: " + fop_run.ExitCode);
248
+ }
249
+ }
250
+
251
+ // Execute fop via shell.Run
252
+ function fop_run() {
253
+ var fop_exec_command = "cmd /" + (keep_open?"K":"C") + " \""
254
+ + "\"" + javacmd + "\" "
255
+ + (config.Exists("JAVA_OPTS")?config.Item("JAVA_OPTS") + " ":"")
256
+ + (config.Exists("LOGCHOICE")?config.Item("LOGCHOICE") + " ":"")
257
+ + (config.Exists("LOGLEVEL")?config.Item("LOGLEVEL") + " ":"")
258
+ + "-classpath \"" + local_classpath + "\" "
259
+ + (config.Exists("FOP_OPTS")?config.Item("FOP_OPTS") + " ":"")
260
+ + "org.apache.fop.cli.Main " + fop_exec_args + "\"";
261
+ if (debug || fop_exec_debug) {
262
+ WScript.Echo(fop_exec_command);
263
+ }
264
+ var exit_code = shell.Run(fop_exec_command, 1, 1);
265
+ if (debug) {
266
+ WScript.Echo("exit status: " + exit_code);
267
+ } else {
268
+ if (exit_code != 0) {
269
+ WScript.Echo("A FOP error occurred (FOP exit status: " + exit_code + ")\n"
270
+ + "Use option --keepopen to see FOP's output\n"
271
+ + "(that is two dashes)");
272
+ }
273
+ }
274
+ }
275
+
276
+ function get_log_choice() {
277
+ // The default commons logger for JDK1.4 is JDK1.4Logger.
278
+ // To use a different logger, uncomment the one desired below
279
+ if (!config.Exists("LOGCHOICE")) {
280
+ // config.Add("LOGCHOICE","\"-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog\"");
281
+ // config.Add("LOGCHOICE","\"-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog\"");
282
+ // config.Add("LOGCHOICE","\"-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger\"");
283
+ if (debug && config.Exists("LOGCHOICE")) {
284
+ WScript.Echo("LOGCHOICE script: " + config.Item("LOGCHOICE"));
285
+ }
286
+ }
287
+ }
288
+
289
+ function get_log_level() {
290
+ // Logging levels
291
+ // Below option is only if you are using SimpleLog instead of the default JDK1.4 Logger.
292
+ // To set logging levels for JDK 1.4 Logger, edit the %JAVA_HOME%/JRE/LIB/logging.properties
293
+ // file instead.
294
+ // Possible SimpleLog values: "trace", "debug", "info" (default), "warn", "error", or "fatal".
295
+ if (!config.Exists("LOGLEVEL")) {
296
+ // config.Add("LOGLEVEL","\"-Dorg.apache.commons.logging.simplelog.defaultlog=INFO\"");
297
+ if (debug && config.Exists("LOGLEVEL")) {
298
+ WScript.Echo("LOGLEVEL script: " + config.Item("LOGLEVEL"));
299
+ }
300
+ }
301
+ }
302
+
303
+ var shell = WScript.CreateObject("WScript.Shell");
304
+ var fs = WScript.CreateObject("Scripting.FileSystemObject");
305
+
306
+ // configuration
307
+ var config = new ActiveXObject("Scripting.Dictionary");
308
+
309
+ read_args();
310
+ read_environment();
311
+ if (!no_config) {
312
+ // read user and system-wide fop configurations
313
+ var spec = shell.SpecialFolders;
314
+ var dts = new Array("Desktop", "AllUsersDesktop");
315
+ for (i in dts) {
316
+ read_desktop(spec(dts[i]));
317
+ }
318
+ // read user and system-wide registry
319
+ var rks = new Array("HKCU", "HKLM");
320
+ for (i in rks) {
321
+ read_registry(rks[i]);
322
+ }
323
+ }
324
+
325
+ get_fop_home();
326
+ get_log_choice();
327
+ get_log_level();
328
+ var javacmd = "";
329
+ get_java_cmd();
330
+ var local_classpath = "";
331
+ get_local_classpath();
332
+
333
+ // Show script help if requested
334
+ if (show_help) {
335
+ // fop_exec_args = "";
336
+ keep_open = true;
337
+ WScript.Echo(help_text);
338
+ }
339
+
340
+ // fop_exec();
341
+ fop_run();