- From: On Lee <onlee2000@hotmail.com>
- Date: Sun, 16 Aug 2009 08:40:48 -0700
- To: "'Danny Ayers'" <danny.ayers@gmail.com>
- Cc: <public-sparql-dev@w3.org>
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. 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. Again, thanks for your help. Best, -- On Lee -----Original Message----- From: public-sparql-dev-request@w3.org [mailto:public-sparql-dev-request@w3.org] On Behalf Of Danny Ayers Sent: Sunday, August 16, 2009 5:37 AM To: On Lee Cc: public-sparql-dev@w3.org Subject: Re: Retrieving all classes 2009/8/14 On Lee <onlee2000@hotmail.com>: > I am reading “A Semantic Web Primer, Second Edition” book. One of the > examples (page 105) is > > > > 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 says that it will retrieve all classes. > > > > But when I executed it on Jena 2.6.0. It returned nothing. What did I do > wrong? I’d appreciate any help/pointer. It's hard to tell without seeing the data you're querying, but a likely explanation is that there really aren't any resources of rdf:type rdfs:Class there. SPARQL doesn't do any inferencing itself, so for them to be picked up by the query such statements need to be declared as instances in the data, e.g. foaf:Person rdf:type rdfs:Class . etc. Alternately, if your instance data contains statements from which inferences can be draw, e.g. <#me> rdf:type foaf:Person . you could use a model with inferencing support, see: http://jena.sourceforge.net/inference/ (in this example from the RDFS axiom: rdf:type rdfs:range rdfs:Class . plus the RDFS rule: aaa rdfs:range xxx . uuu aaa vvv . => vvv rdf:type xxx . ) (btw, it's often convenient to load the vocabularies used alongside instance data into a local store, kind of making it self-documenting, additionally if you do have an inferencing model, giving you a load more derived information). Cheers, Danny. -- http://danny.ayers.name
Received on Sunday, 16 August 2009 15:41:34 UTC