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:[email protected]>
<http://tobyinkster.co.uk>