- From: Paul Gearon <gearon@ieee.org>
- Date: Thu, 5 Nov 2009 16:00:00 -0500
- To: Etienne Morency <etienne.morency@gmail.com>
- Cc: OWL Dev <public-owl-dev@w3.org>
Doh! I've been caught up in function extensions recently, and totally forgot that this can be done with base SPARQL. See below... On Thu, Nov 5, 2009 at 3:00 PM, Paul Gearon <gearon@ieee.org> wrote: > If you don't have an entailment regime, then you can also try to > filter by the structure of the predicate, but you need function > extensions if your triplestore to handle that. For instance, on many > triplestores you could do: > > PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> > SELECT ?sequence ?predicate ?element > WHERE { > ?sequence rdf:type rdf:Seq . > ?sequence ?predicate ?element . > FILTER fn:starts-with( str(?predicate), > "http://www.w3.org/1999/02/22-rdf-syntax-ns#_") > } > > The problem with this approach is that not every SPARQL endpoint > handles this function (yet), or they have similar though differently > named functions. Also, doing these string comparisons could get > expensive if you had a lot of data to return. The better approach is to use regex. FILTER regex(str(?predicate), "^http://www.w3.org/1999/02/22-rdf-syntax-ns#_\d+$") This has the added advantage of ensuring that only numbers are used at the end of the URI (this should be the case, but it's conceivable that someone could write bad URIs). Thanks to Andy Seaborne for pointing out my shortcomings. :-) Regards, Paul Gearon
Received on Thursday, 5 November 2009 21:00:37 UTC