/** * This class shows how to load a DAML ontology from a file and * gives a very elementary way of examining it. */ import com.hp.hpl.jena.daml.*; import com.hp.hpl.jena.daml.common.DAMLModelImpl; import com.hp.hpl.mesa.rdf.jena.model.*; import java.io.*; import java.util.Iterator; public class GEMOntology2 { String url="http://www.servogrid.org/schemas/GEMOntology"; String namespace=url+"#"; DAMLModel model; DAMLDatatype xsdString; public GEMOntology2(String filename) throws RDFException{ model=new DAMLModelImpl(); // model.read("file:///export/home/mpierce/SemanticWeb/GEMExample/GEMOntology.daml"); model.read(filename); } public void iterate(){ Iterator iter=model.listDAMLClasses(); while(iter.hasNext()){ DAMLClass c=(DAMLClass)iter.next(); System.out.println(c.toString()); } } public void dump(OutputStream out) throws RDFException { System.out.println("RDF/XML\n"); model.write(new PrintWriter(out),"RDF/XML-ABBREV",url); } public static void main(String[] args) throws Exception{ if(args.length!=1) { System.out.println("Usage: java GEMOntology2 "); System.out.println("Filename has the format file:///home_dir/sub/file"); System.exit(1); } GEMOntology2 gd2=new GEMOntology2(args[0]); gd2.iterate(); // gd2.dump(System.out); } }