Re: Retrieving all classes

On 16 Aug 2009, at 16:40, On Lee wrote:

> Thanks,Danny.
>
> My data is http://danbri.org/foaf.rdf. I originally loaded it using  
> Jena 2.6.0. It returned nothing. Since I am new and still learning  
> about this technology, I thought I did something wrong.

The key bit is that without some mode of inference engaged by the  
query engine, your sparql query will only return explicit triples from  
the source.

If you open up foaf.rdf in a text editor and search for the string  
"Class" you'll get no hits. Absent entities, that means sparql will do  
no better.

> Later, I learnt from about SPARQLer (http://sparql.org/sparql.html)  
> mentioned in http://www.cambridgesemantics.com/2008/09/sparql-by-example/#%288%29 
> .
>
> I used http://danbri.org/foaf.rdf on the http://sparql.org/ 
> sparql.html and executed
> 	PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> 	PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
>
> 	SELECT  ?c WHERE {  ?c rdf:type rdfs:Class .  }
>
> It returned nothing.
>
> Per your advice/comments below, I changed to the following:
> 	PREFIX rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
> 	PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
> 	PREFIX foaf:   <http://xmlns.com/foaf/0.1/>
>
> 	SELECT  ?c WHERE {  ?c rdf:type foaf:Person .  }
>
> It returns something.

If you string search for "Person", you'll find the syntax for the  
relevant triples, e.g.,

"""   <Person>
         <name>Dan Brickley</name>
         <isPrimaryTopicOf rdf:resource="http://www.geocities.com/danbfan/ 
"/>
         <img rdf:resource="http://www.geocities.com/danbfan/ 
Ford3.jpg"/>
       </Person>""""

That fragment explicitly states the triple:

[] <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person 
 >.

Hence is available as a result.

The current SPARQL wg is working on defining entailment regimes for  
SPARQL which should allow you to query that document with your  
rdfs:Class query and get the expected results.

Unfortunately, it'll be still somewhat complicated by the fact that we  
have both rdfs:Class and owl:Class.

Cheers,
Bijan.

Received on Monday, 17 August 2009 11:25:54 UTC