- From: Alex Kozlenkov <alex.kozlenkov@betfair.com>
- Date: Mon, 26 Jun 2006 13:22:27 +0100
- To: "Public-Rif-Wg \(E-mail\)" <public-rif-wg@w3.org>
Guys, A short update about the SPARQL integration ongoing for the Prova language (prova.ws). It may be used in an upcoming Betfair RIF use case. A new CVS update introduces SPARQL querying mapped to a built-in predicate. The functionality is based on Jena 2.4 ARQ library. The new built-in sparql_select predicate does the job. The predicate is non-deterministic, iterating over one binding (solution) at a time. Here is an example: Code: % Goal :- eval(ex059()). ex059() :- QueryString = ' PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?contributor ?url ?type FROM <http://planetrdf.com/bloggers.rdf> WHERE { ?contributor foaf:name "Bob DuCharme" . ?contributor foaf:weblog ?url . ?contributor rdf:type ?type . } ', sparql_select(QueryString,url(URL),type(Type)|X), println([[url,URL],[type,Type]|X],","). % Prints: % ["url",http://www.snee.com/bobdc.blog/],["type",http://xmlns.com/foaf/0. 1/Agent],["contributor",72260fc5:10c1027fc9f:-7fef] % ["url",http://www.snee.com/bobdc.blog/],["type",http://xmlns.com/foaf/0. 1/Person],["contributor",72260fc5:10c1027fc9f:-7fef] Note that the predicate requires only one parameter, a query string expressed in the SPARQL language. In this case, the actual data will be assumed to be taken from FROM clause. A Jena Model can also be used as a first parameter, in which case the FROM clause is not needed (see the full example ex059.prova). The other arguments of the predicate include name(value) pairs where names are the names of the variables that are returned from the query. The names are assumed to be constant. However, you can also supply a list tail (rest) that will return all name(value) pairs in the resulting binding as a list. If no name(value) pairs and no rest are supplied, the predicate succeeds only if there are matches in the target graph(s). Alex Kozlenkov Advanced Technologies Group www.betfair.com <http://www.betfair.com>
Received on Monday, 26 June 2006 12:23:05 UTC