[Mulgara-general] SPARQL question

Jim Irwin jimirwin at acm.org
Wed Nov 26 20:39:53 UTC 2008


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"/>
    <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"/>
  </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.

Is this a bug in Mulgara's implementation of SPARQL filters, or is this
just an area of ambiguity in the SPARQL spec that allows for different
implementations?

Thanks,
Jim Irwin




More information about the Mulgara-general mailing list