Re: SPARQL Query Problem - perhaps solvable in 1.1?

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 UTC