- From: Seaborne, Andy <andy.seaborne@hp.com>
- Date: Sun, 26 Mar 2006 18:07:30 +0100
- To: Dan Brickley <danbri@danbri.org>
- Cc: Steve Harris <S.W.Harris@ecs.soton.ac.uk>, public-sparql-dev@w3.org, public-swbp-wg@w3.org
Dan Brickley wrote: > * Steve Harris <S.W.Harris@ecs.soton.ac.uk> [2006-03-26 17:15+0100] >> On Sun, Mar 26, 2006 at 10:38:47 -0500, Dan Brickley wrote: >>> >From a blog post I wrote yesterday, http://danbri.org/words/ >>> (where I'm having some connectivity and dns hosting woes, it seems) >>> >>> There's a question buried in here: how do we ask SPARQL for the URIs >>> of properties that appear in FOAF files yet aren't defined in the spec? >>> >>> Suggestions welcomed :) >> I think it can be done with something like: > > Thanks :) > >> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> >> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> >> PREFIX foaf: <http://xmlns.com/foaf/0.1/> >> SELECT DISTINCT ?p >> WHERE { >> ?s ?p ?o >> OPTIONAL { GRAPH foaf: { ?p rdf:type ?prop } >> FILTER(?prop = rdfs:Property) } >> FILTER(REGEX(?p, "^http://xmlns.com/foaf/0.1/") && !BOUND(?prop)) >> } Passes the SPARQLer validator : http://www.sparql.org/validator.html >> >> However when I tried to test it SPARQLer told be it would allow dataset >> building (when I tried to use FROM) and the rasqal demo gave a parse >> error on the FOAF schema. > > Sparqler (the online demo) won't allow FROM? Yes, it does. It does depend on which service you use. Joseki allows deployment of a SPARQl service in two ways: one if a general purpose query service, the other is a service for a single, fixed dataset. The service <http://www.sparql.org/sparql> accepts any SPARQL query and expects the dataset description in the protocol or in the query. I just tested it. The service <http://www.sparql.org/books> does not allow it to be specified and only queries the backing dataset. There different forms for these : see http://www.sparql.org/ You'll want http://www.sparql.org/sparql.html I checked by trying this query to verify ARQ attempts content negotiation stuff: ---- PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?p FROM <http://xmlns.com/foaf/0.1/> { ?p a rdf:Property . FILTER regex(str(?p), "name") } ---- =====>>>>>> { "head": { "vars": [ "p" ] } , "results": { "distinct": false , "ordered": false , "bindings": [ { "p": { "type": "uri" , "value": "http://xmlns.com/foaf/0.1/givenname" } } , { "p": { "type": "uri" , "value": "http://xmlns.com/foaf/0.1/name" } } , { "p": { "type": "uri" , "value": "http://xmlns.com/foaf/0.1/surname" } } , { "p": { "type": "uri" , "value": "http://xmlns.com/foaf/0.1/family_name" } } ] } } JSON being useful to avoid line wrap of tables :-) > > Rasqal's at least didn't > used to, either. Re parse error, maybe ARQ sends a content > negotiation preference for application/rdf+xml while Redland is stuck > looking for RDF inside the XHTML FOAF spec? > > I tried it on commandline with ARQ, and get: > > org/apache/oro/text/regex/MalformedPatternException > > Do we need to escape those '/' chars somehow? or the ':', the '.'? > After some quick experiments, it seems not. Hmm. Hmm. BTW : Old version alert : ARQ does not use ORO now. > > So you can run a regex directly against ?p, without casting it to a > string? That's handy/grungy... No - you will need the str() or else get runtime exceptions (causing no results). See example above: You can try out expressions with ARQ with the command line arq.qexpr arq.qexpr 'regex(<http://example>, "example")' ==> Exception: REGEX: <http://example> evaluates to <http://example>, which is not a string. arq.qexpr 'regex("example", "example")' ==> true You can use it as an arbitrary precision calculator (patience helps). Some namespaces are built in for convenience. Andy > > On the query itself, once this part works, I guess I can scope the > ?s ?p ?o part to a set of named graphs, rather than the default graph? > (I need this in a real app, where we're checking healthcare records are > all using properly defined properties). > > I would have expected there'd be some way to express all of this in > terms of named graphs and !bound(), rather than relying on string > matching against property URIs. But I've not spent much time with > this corner of SPARQL yet. Is it inexpressible? > > cheers, > > Dan > >> - Steve >
Received on Sunday, 26 March 2006 17:08:35 UTC