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 12:37:45 UTC