Skip to content

Instantly share code, notes, and snippets.

@datablend
Created July 8, 2011 18:21
Show Gist options
  • Save datablend/1072438 to your computer and use it in GitHub Desktop.
Save datablend/1072438 to your computer and use it in GitHub Desktop.
// Create query
TupleQuery durationquery = connection.prepareTupleQuery(QueryLanguage.SPARQL,
"PREFIX io: <http://www.daml.org/2001/06/itinerary/itinerary-ont#> " +
"PREFIX fl: <http://www.snee.com/ns/flights#> " +
"SELECT ?number ?departure ?destination " +
"WHERE { " +
"?flight io:flight ?number . " +
"?flight fl:flightFromCityName ?departure . " +
"?flight fl:flightToCityName ?destination . " +
"?flight io:duration \"1:35\" . " +
"}");
// Evaluate and print results
TupleQueryResult result = durationquery.evaluate();
while (result.hasNext()) {
BindingSet binding = result.next();
System.out.println(binding.getBinding("number").getValue() + " " +
binding.getBinding("departure").getValue() + " " +
binding.getBinding("destination").getValue());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment