-- 作者:zghydx02wl
-- 发布时间:10/24/2011 4:23:00 PM
-- 使用eclipse 解析owl-s遇到问题,请教高手
owl-s api使用的owl-s-1.1.0版本。 代码如下: import impl.jena.JenaOWLFactory; import impl.owls.process.execution.ProcessExecutionEngineImpl; import java.net.URI; import org.mindswap.owl.OWLClass; import org.mindswap.owl.OWLDataProperty; import org.mindswap.owl.OWLFactory; import org.mindswap.owl.OWLIndividual; import org.mindswap.owl.OWLKnowledgeBase; import org.mindswap.owl.OWLOntology; import org.mindswap.owl.list.RDFList; import org.mindswap.owls.OWLSFactory; import org.mindswap.owls.process.CompositeProcess; import org.mindswap.owls.process.ForEach; import org.mindswap.owls.process.Input; import org.mindswap.owls.process.Local; import org.mindswap.owls.process.Perform; import org.mindswap.owls.process.Process; import org.mindswap.owls.process.execution.ProcessExecutionEngine; import org.mindswap.owls.service.Service; import org.mindswap.owls.vocabulary.OWLS; import org.mindswap.query.ValueMap; /** * * Example to show how to create and execute a forEach control construct. * * @author Evren Sirin */ public class ForEachExample { public void run() throws Exception { String ns = "http://www.example.org/test #"; // print the inputs and outputs during each iteration of the loop ProcessExecutionEngineImpl.DEBUG = true; ProcessExecutionEngine exec = OWLSFactory.createExecutionEngine(); OWLKnowledgeBase ab = OWLFactory.createKB(); Service service = ab.readService("http://www.mindswap.org/2004/owl-s/1.1/FindLatLong.owl" ); Process process = service.getProcess(); OWLOntology ont = ab.createOntology(); CompositeProcess cp = ont.createCompositeProcess(); Input in = ont.createInput(URI.create( ns + "in" )); in.setParamType(OWLS.ObjList.List()); cp.addInput(in); // create a ForEach construct ForEach forEach = ont.createForEach(); Local loopVar = ont.createLocal( URI.create( ns + "loopVar") ); cp.setComposedOf(forEach); forEach.setListValue( Perform.TheParentPerform, in ); forEach.setLoopVar( loopVar ); // perform the process by passing the loop variable Perform perform = ont.createPerform(); perform.setProcess(process); perform.addBinding(process.getInput(), Perform.TheParentPerform, loopVar); forEach.setComponent(perform); // display how the construct looks like in RDF/XML ont.write(System.out); // create some zip code values String zipcodeOnt = "http://www.daml.org/2001/10/html/zipcode-ont #"; OWLClass ZipCode = ab.getClass(URI.create(zipcodeOnt + "ZipCode")); OWLDataProperty zip = ab.getDataProperty(URI.create(zipcodeOnt + "zip")); OWLIndividual zip1 = ont.createInstance(ZipCode); zip1.setProperty(zip, "20740"); OWLIndividual zip2 = ont.createInstance(ZipCode); zip2.setProperty(zip, "11430"); OWLIndividual zip3 = ont.createInstance(ZipCode); zip3.setProperty(zip, "94102"); // put them in a list RDFList list = ont.createList(zip1).add(zip2).add(zip3); ValueMap values = new ValueMap(); values.setValue(cp.getInput("in"), list); exec.execute( cp , values ); } public static void main(String[] args) throws Exception { ForEachExample test = new ForEachExample(); test.run(); } } 错误:Exception in thread "main" java.lang.NoClassDefFoundError: com/hp/hpl/jena/query/core/ElementFilter at impl.jena.JenaOWLFactory.createKB(JenaOWLFactory.java:87) at org.mindswap.owl.OWLFactory.createKB(OWLFactory.java:90) at CreateSequence.runTest(CreateSequence.java:207) at CreateSequence.main(CreateSequence.java:254) Caused by: java.lang.ClassNotFoundException: com.hp.hpl.jena.query.core.ElementFilter at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 4 more 报错说缺少类,但是api包里没有那些累。是我哪里出错了?
|