01: /*
02: * This file or a portion of this file is licensed under the terms of
03: * the Globus Toolkit Public License, found in file GTPL, or at
04: * http://www.globus.org/toolkit/download/license.html. This notice must
05: * appear in redistributions of this file, with or without modification.
06: *
07: * Redistributions of this Software, with or without modification, must
08: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
09: * some other similar material which is provided with the Software (if
10: * any).
11: *
12: * Copyright 1999-2004 University of Chicago and The University of
13: * Southern California. All rights reserved.
14: */
15:
16: package org.griphyn.vdl.parser;
17:
18: import org.griphyn.vdl.classes.*;
19: import org.griphyn.vdl.util.*;
20: import java.io.*;
21:
22: /**
23: * This class is used to test the <code>VDLxParser</code> class and
24: * the input file index. It parses all the XML documents specified
25: * in the commandline, creates the corresponding java objects, and
26: * generates an XML document from these objects. It also prints
27: * the input file list if the last definition in the document is
28: * a derivation.
29: *
30: * @author Jens-S. Vöckler
31: * @author Yong Zhao
32: * @version $Revision: 50 $
33: *
34: * @see VDLxParser
35: * @see org.griphyn.vdl.classes.Definitions
36: * @see org.griphyn.vdl.classes.Derivation
37: */
38:
39: public class VDLxTest {
40: static public void main(String[] args) throws IOException {
41: if (args.length == 0) {
42: System.err.println("Usage: java VDLxTest [xmlURI] ...");
43: return;
44: }
45: // connect debug stream
46: Logging.instance().register("filler", System.out);
47: Logging.instance().register("parser", System.out);
48: Logging.instance().register("app", System.out);
49:
50: VDLxParser parser = new VDLxParser(System
51: .getProperty("vds.schema.vdl"));
52: for (int i = 0; i < args.length; i++) {
53: Logging.instance().log("app", 1,
54: "starting to read from " + args[i]);
55: Definitions def = new Definitions();
56: parser.parse(new org.xml.sax.InputSource(
57: new BufferedInputStream(
58: new FileInputStream(args[i]))),
59: new MemoryStorage(def, true, true));
60: Logging.instance()
61: .log(
62: "app",
63: 1,
64: "read " + def.getDefinitionCount()
65: + " definitions");
66:
67: String outfn = args[i] + ".xml";
68: Logging.instance().log("app", 1,
69: "dumping results to " + outfn);
70: def.toXML(new OutputStreamWriter(new BufferedOutputStream(
71: new FileOutputStream(outfn))), "");
72: Logging.instance().log("app", 1, "done dumping results");
73: }
74: }
75: }
|