W3C home > Mailing lists > Public > semantic-web@w3.org > May 2005

Re: SPARQL queries: resource identifier/rdf:about

From: Jeen Broekstra <jeen@aduna.biz>
Date: Tue, 10 May 2005 10:12:33 +0200
Message-ID: <42806CF1.1060103@aduna.biz>
To: conor dowling <conor@the325project.org>
Cc: semantic-web@w3.org

conor dowling wrote:

> first off, thx very much for the info Jeen. One last question on 
> "rdf:about" or rather the value of "?subject" ...
>>
>>> 2) rdf:about value and value of "?subject"
>>> # can I get the "rdf:about" from every resource
>>> PREFIX rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
>>> SELECT ?subject
>>> WHERE { ?subject rdf:about ?about }
>>
>>
>> No.
>>
>> rdf:about is not an actual property, but is simply a bit of syntax in
>> the RDF/XML serialization that is used to denote the subject of a
>> triple. It does not occur in the RDF graph and can not be queried
>> through SPARQL (or any other RDF query language that I know of).
> 
> 
> but is the value returned in ?subject is equivalent to rdf:about in 
> RDF/XML?
> 
> SELECT ?subject

Ah, maybe I misunderstand but you seem to be under the impression that 
'?subject' is some sort of "special" variable that is always bound to 
the subject of triples. This is not the case. There are no special 
variables in SPARQL. The name of the variable is simply something the 
writer of the query comes up with. Binding of a variable to a value 
always happens by matching it through a graph pattern in the where-clause.

To illustrate:

SELECT ?subject
WHERE { ?subject ?predicate ?object }

is exactly equivalent to:

SELECT ?foo
WHERE { ?foo ?bar ?foobar }

> Let's say I assign it to a variable "subjectIdentifier". Then can I say ...
> 
> SELECT ?name
> WHERE {subjectIdentifier dc:title ?name}
> 
> (assuming of course that dc:title is supported by that subject ...).

I'm afraid I don't quite follow this example. Let's take that bit of 
RDF/XML I posted earlier again:

<rdf:RDF
    ...
    xmlns:ex="http://example.org/colors/">
...
<rdf:Description rdf:about="#myCar">
    <ex:hasColor>red</ex:hasColor>
</rdf:Description>
...
</rdf:RDF>

This encodes a single RDF triple. The subject is "#myCar", or rather, 
the full URI that comes from resolving the "#myCar" against the base 
URI of the document. Supposing the document is at 
http://example.org/cars/, the full triple becomes:

   http://example.org/car/myCar http://example.org/hasColor "red" .

Now if you want to query for all color values in SPARQL, you'd do:

@PREFIX ex: <http://example.org/colors/>
SELECT ?color
WHERE { ?x ex:hasColor ?color }

If you wanted to query for the color of that specific car "myCar", 
you'd do:

@PREFIX ex: <http://example.org/colors/>
SELECT ?color
WHERE { <http://example.org/car/myCar> ex:hasColor ?color }

Note that if you have a triple with a blank node (for example, when 
you specify one in XML without an rdf:about attribute) you can not do 
this last type of query. You will have to identify such subjects by 
means of the property values that they have.

> In 
> other words, can I use the subject id's across queries to that data 
> source? Is the subject id data source dependent,  nothing more than a 
> convenient resource identifier for use within that data source?

The subject of an RDF triple is either a full URI, in which case it is 
source-independent and can be referenced across queries, or a blank 
node in which case it only has a source-dependent identifier (a "blank 
node id") which can not be referenced directly in queries at all.

I hope this clarifies it!

Regards,

Jeen
-- 
Jeen Broekstra          Aduna BV
Knowledge Engineer      Julianaplein 14b, 3817 CS Amersfoort
http://aduna.biz        The Netherlands
tel. +31 33 46599877
Received on Tuesday, 10 May 2005 08:10:30 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 21:45:05 GMT