You get no results because you are querying the empty model1
while all of your results are contained in model
. Simply change:
OntModel model1=ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
... to ...
OntModel model1=ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM, model);
... and then your subsequent query will have access to the triples inside of the OntModel
. The proof is found on the line where you create your QueryExecution
instance:
QueryExecution exe=QueryExecutionFactory.create(query, model1);
On this line, you create a query that references the new model, which has none of the triples that you read in from your file.