From: Anne B. <bj...@si...> - 2012-06-08 12:17:50
|
Hi! I'm playing around with the Semantic Web Cllient Library. I have been trying to get the example from the website to work, but without luck. Could you tell me what is going wrong with it. My code is: public void queryWeb(){ SemanticWebClient semweb = new SemanticWebClient(); semweb.getConfig().setValue(SemanticWebClientConfig.MAXSTEPS, "5" ); // Specify the query. String queryString1 = "PREFIX foaf:<http://xmlns.com/foaf/0.1/> " + "SELECT DISTINCT ?friendsname ?friendshomepage ?foafsname ?foafshomepage " + "WHERE {" + " { <http://richard.cyganiak.de/foaf.rdf#cygri> foaf:knows ?friend ." + " ?friend foaf:mbox_sha1sum ?mbox . " + " ?friendsURI foaf:mbox_sha1sum ?mbox ." + " ?friendsURI foaf:name ?friendsname ." + " ?friendsURI foaf:homepage ?friendshomepage . }" + " OPTIONAL { ?friendsURI foaf:knows ?foaf ." + " ?foaf foaf:name ?foafsname ." + " ?foaf foaf:homepage ?foafshomepage ." + " } " + " }" ; // Execute the query and obtain results. Query query = QueryFactory.create(queryString1); QueryExecution qe = QueryExecutionFactory.create(query, semweb.asJenaModel("default")); ResultSet results = qe.execSelect(); //Output query results. ResultSetFormatter.out(System.out, results, query); List<String> suc = semweb.successfullyDereferencedURIs(); Set<String> unsuc = semweb.unsuccessfullyDereferencedURIs(); semweb.close(); System.out.println("Successfull uris"); for(String s : suc){System.out.println(s);} System.out.println("Unsuccessfull uris"); for(String s : unsuc){System.out.println(s);} } and the result is: INFO: ----------------------------------------------------------------------------------------------- | friendsname | friendshomepage | foafsname | foafshomepage | =============================================================================================== | "Max Völkel" | <http://www.xam.de/> | | | | "Sven Schwarz" | <http://www.dfki.uni-kl.de/~schwarz/> | | | | "Arne Handt" | <http://handtwerk.de/> | | | | "Arne Handt" | <http://www.handtwerk.de<http://www.handtwerk.de/>> | | | | "David Best" | <http://www.david-best.de/> | | | | "Giovanni Tummarello" | <http://g1o.net/> | | | | "Thomas Roth-Berghofer" | <http://thomas.roth-berghofer.de/> | | | | "Robert Tolksdorf" | <http://www.robert-tolksdorf.de<http://www.robert-tolksdorf.de/>> | | | ----------------------------------------------------------------------------------------------- INFO: Successfull uris INFO: Unsuccessfull uris INFO: http://www.david-best.de/foaf.rdf INFO: http://thomas.roth-berghofer.de/foaf.xml INFO: http://www.handtwerk.de/foaf.rdf INFO: http://people.aifb.kit.edu/mvo/foaf.rdf.xml INFO: http://leo.gnowsis.com/outlook/contact/00000000ECD4B99358B9814B9DAFE2255CD8AE9A44B42F00 INFO: http://g1o.net/ INFO: http://g1o.net/g1ofoaf.xml INFO: http://page.mi.fu-berlin.de/best/foaf.rdf INFO: http://www.david-best.de/ So, I don't seem to be able to get on from the original uri???? Kind regards Anne |