Bug #174
openFILTERs external to an OPTIONAL applied inside the OPTIONAL
0%
Description
Based on Jim Irwin's report:
I wrote a SPARQL query that attempts to find all the root classes of an
ontology, i.e. those that are not subclasses of classes other than
owl:Thing and rdfs:Class.
Setting aside for the moment the question of whether this is the best
approach to finding the root classes, here is the SPARQL that I ran:
SELECT DISTINCT ?root
WHERE
{
{
{ ?root rdf:type owl:Class . }
UNION
{ ?root rdf:type rdfs:Class . }
FILTER ( (?root != owl:Thing) && (?root != rdfs:Class) )
}
OPTIONAL {
?root rdfs:subClassOf ?sup .
FILTER ( (?sup != owl:Thing) && (?sup != rdfs:Class) )
}
FILTER ( !bound(?sup) )
}
ORDER BY ?root
}}
I ran the query against the FOAF ontology, and got eight results:
http://www.w3.org/2000/10/swap/pim/contact#Person
http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing
http://xmlns.com/wordnet/1.6/Agent
http://xmlns.com/wordnet/1.6/Agent-3
http://xmlns.com/wordnet/1.6/Document
http://xmlns.com/wordnet/1.6/Organization
http://xmlns.com/wordnet/1.6/Person
http://xmlns.com/wordnet/1.6/Project
However, there is actually another root class in FOAF, the
foaf:OnlineAccount class. That class is defined as
<owl:Class rdf:about="OnlineAccount">
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Class&quot;/>
<vs:term_status>unstable</vs:term_status>
<rdfs:label>Online Account</rdfs:label>
<rdfs:comment>An online account.</rdfs:comment>
<rdfs:isDefinedBy rdf:resource=""/>
<rdfs:subClassOf rdf:resource="http://www.w3.org/2002/07/owl#Thing&quot;/>
</owl:Class>
Note the foaf:OnlineAccount rdfs:subClassOf owl:Thing triple.
Here's my question: In my SPARQL query's OPTIONAL group, I filter out
all the rdfs:subClassOf triples that contain owl:Thing or rdfs:Class as
the object. So I would expect that the ?sup variable would not be bound
outside that group, and that foaf:OnlineAccount would pass the
!bound(?sup) filter. However, it appears that it does not pass the
filter, as if the !bound filter were being applied inside the OPTIONAL
group rather than outside it.
Just for comparison, I ran the same query using Jena, and
foaf:OnlineAccount does appear in the results list when using Jena, as I
would expect it to.
No data to display