I am new to sparql query. I have the following query. I am trying to retrieve range and domain from owl file. I am getting output in protege. But for the same query I am not getting any output in eclipse.
This is a very simple ontology.
I am just having 3 classes. Water, Herd and pasture
One object property - req
I have defined herd and pasture as domain for obejct property "req" and water as range.
When I execute the below query in protege, i am getting herd and pasture as output for domains, water for range. But in java, it simply prints range and domain headers.
Can anyone assist me regarding this? Thanks in advance. Below is the code in eclipse. I tried saving file in RDF format as well as owl. But no luck.
OntModel model1 = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_RULE_INF);
File file=new File("C:\\Users\\anithat\\Desktop\\finalcheck.owl");
FileInputStream reader=new FileInputStream(file);
model1.read(reader,null);
String queryString = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" +
"PREFIX owl: <http://www.w3.org/2002/07/owl#>" +
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "+
"PREFIX rdfs: <http://www.semanticweb.org/anithat/ontologies/2020/6/untitled-ontology-30#>" +
"SELECT ?range ?domain { rdfs:req rdfs:domain ?domain . "
+ "rdfs:req rdfs:range ?water .}";
Query query = QueryFactory.create(queryString);
QueryExecution qe= QueryExecutionFactory.create(query, model1);
ResultSet resultset = qe.execSelect();
ResultSetFormatter.out(System.out, resultset, query);