W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > July to September 2009

Re: SPARQL Query Problem - perhaps solvable in 1.1?

From: Dan Brickley <danbri@danbri.org>
Date: Tue, 25 Aug 2009 14:49:20 +0200
Message-ID: <eb19f3360908250549g32d27e4bp1c82949c82c93a96@mail.gmail.com>
To: Lee Feigenbaum <lee@thefigtrees.net>
Cc: Toby Inkster <tai@g5n.co.uk>, public-rdf-dawg@w3.org, public-sparql-dev@w3.org
On Tue, Aug 25, 2009 at 2:45 PM, Lee Feigenbaum<lee@thefigtrees.net> wrote:
> Hi Toby,
>
> I've CCed the SPARQL WG list but also the public-sparql-dev list which in
> general is better suited for "how do I..." SPARQL questions. If I'm correct
> that that best suits the nature of this question, please drop
> public-rdf-dawg@w3.org from future messages in this thread.
>
> If I understand you correctly, the pattern you're looking for is that you
> have a prioritized list of predicates that you want to use for a particular
> value, in this case date. The "canonical" way to do this in SPARQL (or, at
> least, what I've always done and seen done) is to use a series of OPTIONAL
> clauses that all bind to the same variable:
>
> SELECT ?date {
>   ?item a ex:Item .
>   OPTIONAL { ?item dct:created ?date }
>   OPTIONAL { ?item dct:issued ?date }
>   OPTIONAL { ?item dct:date ?date }
>   OPTIONAL { ?item dc:date ?date }
> } ORDER BY ?date
>
> This will bind ?date to the first of the predicates that have a value for
> each ex:Item.

First in the query (textually, ie. created before issued before date,
...), or first in the data?

If the former - I hadn't realised OPTIONAL was ordered, if it is...

cheers,

Dan
Received on Tuesday, 25 August 2009 12:50:01 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:08:26 GMT