- From: Toby Inkster <tai@g5n.co.uk>
- Date: Tue, 25 Aug 2009 14:00:46 +0100
- To: Lee Feigenbaum <lee@thefigtrees.net>
- Cc: public-rdf-dawg-comments@w3.org, public-sparql-dev@w3.org
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@tobyinkster.co.uk> <http://tobyinkster.co.uk>
Received on Tuesday, 25 August 2009 13:01:43 UTC