I have this java code that, using apache jena api, queries the pizza ontology
String queryStr =
"prefix pizza: <" + PIZZA_NS + "> " +
"prefix rdfs: <" + RDFS.getURI() + "> " +
"prefix owl: <" + OWL.getURI() + "> " +
"select ?pizza where {?pizza a owl:Class ; " +
"rdfs:subClassOf ?restriction. " +
"?restriction owl:onProperty pizza:hasTopping ;" +
"owl:someValuesFrom pizza:PeperoniSausageTopping" +
"}";
Query query = QueryFactory.create(queryStr);
QueryExecution qe = QueryExecutionFactory.create(query, model);
ResultSet rs = qe.execSelect();
ArrayList rsList = (ArrayList)ResultSetFormatter.toList(rs);
for(int i=0;i<rsList.size();i++){
out.println(rsList.get(i).toString());
}
It returns this:
( ?pizza = <http://www.co-ode.org/ontologies/pizza/pizza.owl#AmericanHot> )
( ?pizza = <http://www.co-ode.org/ontologies/pizza/pizza.owl#FourSeasons> )
( ?pizza = <http://www.co-ode.org/ontologies/pizza/pizza.owl#American> )
but I need only
AmericanHot
FourSeasons
American
How to obtain this result?
The SPARQL 1.1 function STRAFTER can help:
but the client side solution is just as good and works with SPARQL 1.0.