Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/embl/ebi/escience/scufl/parser/test/XScuflParserTest.java


1   /**
2    * This file is a component of the Taverna project,
3    * and is licensed under the GNU LGPL.
4    * Copyright Tom Oinn, EMBL-EBI
5    */
6   package org.embl.ebi.escience.scufl.parser.test;
7   
8   import org.embl.ebi.escience.scufl.ScuflModel;
9   import org.embl.ebi.escience.scufl.ScuflModelEventPrinter;
10  import org.embl.ebi.escience.scufl.parser.XScuflParser;
11  import org.embl.ebi.escience.scufl.view.XScuflView;
12  
13  // Network Imports
14  import java.net.URL;
15  
16  import java.lang.ClassLoader;
17  import java.lang.Exception;
18  import java.lang.String;
19  import java.lang.System;
20  import java.lang.Thread;
21  
22  
23  
24  /**
25   * Attempt to load a chunk of XScufl into a model
26   * @author Tom Oinn
27   */
28  public class XScuflParserTest {
29  
30      public static void main(String args[]) throws Exception {
31    
32    // Create a new ScuflModel and add the trivial listener
33    // to print out all events on it
34    ScuflModel model = new ScuflModel();
35    model.addListener(new ScuflModelEventPrinter(null));
36    XScuflView view = new XScuflView(model);
37  
38    // Load the XScufl chunk from the test package
39    ClassLoader loader = Thread.currentThread().getContextClassLoader();
40    URL location = loader.getResource("org/embl/ebi/escience/scufl/parser/test/example_sink_source.xml");
41    System.out.println("Loading definition from : "+location.toString());
42    // Use it to populate the model, names do not have
43    // prefixes applied to them.
44    XScuflParser.populate(location.openStream(), model, null);
45    
46    // And then do the same, but prefixing with 'foo' to test that
47    // we can import more than one model.
48    location = loader.getResource("org/embl/ebi/escience/scufl/parser/test/example_sink_source.xml");
49    System.out.println("Loading definition from : "+location.toString());
50    XScuflParser.populate(location.openStream(), model, "foo");
51    
52    System.out.println(view.getXMLText());
53      }
54  
55  }