Re: SPARQL Query Problem - perhaps solvable in 1.1?

View: New views
1 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: SPARQL Query Problem - perhaps solvable in 1.1?

by Toby Inkster-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, 2009-08-25 at 08:45 -0400, Lee Feigenbaum wrote:

> 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

Wow! That actually seems to work! How did I not spot this?

It means I lose out on knowing which of the predicates worked, so I
can't perfectly reconstruct the original triples in my application. But
that, I think I can live with.

Nevertheless I think a COALESCE function would still be a useful
addition to SPARQL 1.1.

--
Toby A Inkster
<mailto:mail@...>
<http://tobyinkster.co.uk>