2
votes

I tried to run the following SPARQL query in Sesame:

SELECT ?s ?p 
FROM <http://namespace#ABox> 
FROM <http://namespace#TBox> 
WHERE { ?s ?p <http://namespace#Sensor> }

according: run a sparql query against two graphs?

the following rdf-statements are stored in Sesame:

subject:   <http://namespace#Sensor2014>  
predicate: <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>  
object:    <http://namespace#TempSensor>  
context:   <http://namespace#ABox> 

subject:   <http://namespace#TempSensor>  
predicate: <http://www.w3.org/2000/01/rdf-schema#subClassOf>  
object:    <http://namespace#Sensor>  
context:   <http://namespace#TBox>

I used the option setIncludeInferred(true) in Java

Only the following statement appears:

subject:   <http://namespace#TempSensor>  
predicate: <http://www.w3.org/2000/01/rdf-schema#subClassOf>

Actually I expect to get Sensor2014 also as a result.

I think the problem might be the OWLSubClassOfAxiom

Update:

I tried the following queries:

First query:

SELECT ?s ?p  WHERE {?s ?p <http://namespace#Sensor>}

result:

subject:   <http://namespace#Sensor2015>
predicate: <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>

result is the expected one

Second query:

SELECT ?s ?p FROM <http://namespace#TAbox>  WHERE {?s ?p <http://namespace#Sensor>}

no results

result is not the expected one

Now both, ABox and TBox, are in the same subgraph. content of subgraph:

subject:   <http://namespace#Sensor2015>
predicate: <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
object:    <http://namespace#TempSensor>    
context:   <http://namespace:TAbox>

subject:   <http://namespace#TempSensor>  
predicate: <http://www.w3.org/2000/01/rdf-schema#subClassOf>  
object:    <http://namespace#Sensor>  
context:   <http://namespace:TAbox>

Reasoning is supported - proved in first query. I conclude by trying the queries that as soon as a subgraph is used, reasoning does not work anymore.

1
FROM <namespace#ABox> FROM <namespace#TBox> looks very suspicious to me. Are you actually using relative URIs as the names of graphs? I'm not even sure whether that's legal. In any case, it seems like it might lead to unpredictable results. If that's not your actual code, then please provide us code that we can use to reproduce the problem. - Joshua Taylor
It was a mistake. Absolute URIs are used. It is now corrected. - user3616092

1 Answers

1
votes

Your SPARQL WHERE clause looks for all subjects and all predicates that have <http://namespace#Sensor> as an object. Looking at your data only the second triple matches this pattern. The first triple has <http://namespace#TempSensor> has an object.

You haven't specified whether you used a Repository with inference or not, so assuming a standard non-inference in-memory or native repository, the result you have looks normal to me.