RE: Retrieving all classes


My data is 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 ( mentioned in 

I used on the and executed
 PREFIX rdf:     <>
 PREFIX rdfs:    <>

 SELECT  ?c WHERE {  ?c rdf:type rdfs:Class .  } 

It returned nothing.

Per your advice/comments below, I changed to the following:
 PREFIX rdf:     <>
 PREFIX rdfs:    <>
 PREFIX foaf:   <>

 SELECT  ?c WHERE {  ?c rdf:type foaf:Person .  }

It returns something.

Again, thanks for your help.

-- On Lee

-----Original Message-----
From: [] On Behalf Of Danny Ayers
Sent: Sunday, August 16, 2009 5:37 AM
To: On Lee
Subject: Re: Retrieving all classes

2009/8/14 On Lee <>:
> I am reading “A Semantic Web Primer, Second Edition” book. One of the
> examples (page 105) is
> PREFIX rdf:     <>
> PREFIX rdfs:    <>
>  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 .

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:

(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).



Received on Sunday, 16 August 2009 15:41:34 UTC