Hi everyone
I use Protege Version 3.4.7 (Build 620) and execute a simple query in the
SPARQL Query Panel on http://www.co-ode.org/ontologies/pizza/pizza.owl:
SELECT ?NombrePizza
> WHERE {
> ?NombrePizza ?Relacion pizza:MushroomTopping .
> ?Relacion owl:inverseOf pizza:isToppingOf .
> }
The result is 4 pizzas:
DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#FourSeasons)
DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#Mushroom)
DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#Giardiniera)
DefaultOWLNamedClass(
> http://www.co-ode.org/ontologies/pizza/pizza.owl#LaReine)
Then I execute the same query with jena
package Jena;
> import com.hp.hpl.jena.graph.query.Query;
> import com.hp.hpl.jena.query.*;
> import com.hp.hpl.jena.rdf.model.*;
> import com.hp.hpl.jena.reasoner.Reasoner;
> import com.hp.hpl.jena.reasoner.ReasonerRegistry;
> import com.hp.hpl.jena.reasoner.ValidityReport;
> import java.util.Iterator;
> public class Test {
>
> public static void main(String args[]) {
> Model model = ModelFactory.createDefaultModel();
> model.read("http://localhost:8080/volcano/w3/pizza-latest.owl",
> "RDF/XML");
>
> model.write(System.out);
>
> Reasoner reasoner = ReasonerRegistry.getOWLMicroReasoner();
> InfModel inf = ModelFactory.createInfModel(reasoner, model);
>
> ValidityReport validity = inf.validate();
> if (validity.isValid()) {
> System.out.println("OK: El Modelo Inferido es correcto.");
> } else {
> System.out.println("Conflictos");
> for (Iterator i = validity.getReports(); i.hasNext();) {
> System.out.println(" - " + i.next());
> }
> }
>
> inf.write(System.out);
>
> String prefix = "PREFIX pizza:<
> http://www.co-ode.org/ontologies/pizza/pizza.owl#>"
> + " PREFIX owl:<http://www.w3.org/2002/07/owl#>"
> + " PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>";
>
> String queryString1 = prefix + " SELECT ?NombrePizza WHERE {"
> + " ?NombrePizza ?Relacion pizza:MushroomTopping ."
> + " ?Relacion owl:inverseOf pizza:isToppingOf }";
>
> com.hp.hpl.jena.query.Query query =
> QueryFactory.create(queryString1) ;
> QueryExecution qexec = QueryExecutionFactory.create(query, inf);
>
> try {
> ResultSet results = qexec.execSelect() ;
> ResultSetFormatter.out(results, query);
> } finally {
> qexec.close();
> }
> }
> }
And the result is empty:
-----------------------
> | NombrePizza |
> ============
> -----------------------
I don't know what is my mistake. Do you have any idea?. Thank you very much.
- - -
FAZA