我有这个 java 代码,它使用 apache jena api 查询披萨本体
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());
}
它返回这个:
( ?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> )
但我只需要
美国热
四个季节
美国人
如何获得这个结果?