I have an ontology (dgo.owl) and a simple program (SparqlQuery.java) to query the same ontology. On running the query I do not get any results. After debugging for a long time I thought it would be good to put it in the community.
The query script is as:
OntModel ontmodque = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
InputStream in=FileManager.get().open("ontologies/dgo.owl");
if (ontmodque.isEmpty())
{
ontmodque.read(in,"RDF/XML");
}
String qr= "PREFIX ssn: <http://purl.oclc.org/NET/ssnx/ssn#>\n" +
"PREFIX dgo: <http://www.iiitd.edu.in/~haroonr/ontologies/DGO#>\n" +
"SELECT \n"+
"?property \n"+
"WHERE\n"+
"{ \n"+
"dgo:DiningRoom ssn:hasProperty ?property .\n " +
"}";
Query qy = QueryFactory.create(qr);
QueryExecution qe = QueryExecutionFactory.create(qy,ontmodque);
ResultSet rs= qe.execSelect();
ResultSetFormatter.out(System.out, rs, qy) ;
ontmodque.close();
qe.close();
Output obtained is:
I know that hasProperty object relationship is present in said ontology. Also, possible properties for the DiningRoom should return Illuminance, Temperature, Co2Content,AbsoluteHumidity.