- From: Yosi Scharf <syosi@MIT.EDU>
- Date: Wed, 10 Aug 2005 14:47:08 -0400
- To: public-cwm-talk@w3.org
- CC: syosi@MIT.EDU
Cwm can now has support for being a SPARQL server. To learn more about SPARQL, see http://www.w3.org/TR/rdf-sparql-query/ There are several pieces to this support. (1) http://www.w3.org/2000/10/swap/grammar/sparql is a machine readable grammar for sparql. (2) in the http://www.w3.org/2000/10/swap/sparql/ directory there is sparql_parser.py, which uses a LL(1) table generated from sparql.n3 to generate a parse tree. (3) http://www.w3.org/2000/10/swap/sparql2cwm.py which compiles the SPARQL into n3. Actually looking at what is generated is fascinating in my opinion, but far from necessary [1]. (4) builtins used in the converted n3. These are defined in http://www.w3.org/2000/10/swap/sparqlCwm , and implemented in http://www.w3.org/2000/10/swap/cwm_sparql.py. (5) Modifications to the cwm query engine to support sparql's error handling. --mode=q enables these if you are not doing a SPARQL query. (6) command line arguments for using sparql. --sparql= is usable in the same way as --query= . Also, --language=sparql tells cwm that the following file is sparql. (7) builtins for using cwm's SPARQL support from within n3. These are also defined at http://www.w3.org/2000/10/swap/sparqlCwm , and implemented in http://www.w3.org/2000/10/swap/cwm_sparql.py . (8) Fixes to cwm's xml output class to allow for the outputting of the SPARQL results format. (9) A (experimental) Cwm sparql server. if cwm sees --sparqlServer on the command line, at that point in processing it stops and starts an http server on port 8000. I have one of these running for now at mr-burns.w3.org:8000 (no guarentees about how long that will stay up). Tests for cwm's SPARQL support are listed in http://www.w3.org/2000/10/swap/test/sparql/detailed.tests . Known Limitations: - Cwm does not support result ordering or limiting at this time. If you specify an order of the results or a limit, cwm with throw a NotImplementedError. - The order of the variables given in a SELECT query is not preserved. - DESCRIBE queries are not supported. - Some queries involving lists [2] will fail. Yosi -------------------------------------------- [1] here is a simple example of the transformation: syosi@mr-burns:~/CVS-local/WWW/2000/10/swap/test/sparql$ cat test1.sparql PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?mbox WHERE { ?x foaf:name "Johnny Lee Outlaw" . ?x foaf:mbox ?mbox } syosi@mr-burns:~/CVS-local/WWW/2000/10/swap/test/sparql$ cwm --language=sparql test1.sparql #Processed by Id: cwm.py,v 1.176 2005/08/10 17:03:22 syosi Exp # using base file:/home/syosi/CVS-local/WWW/2000/10/swap/test/sparql/test1.sparql loaded from file 1.59013986588 # Notation3 generation by # notation3.py,v 1.180 2005/06/09 21:05:14 syosi Exp # Base was: file:/home/syosi/CVS-local/WWW/2000/10/swap/test/sparql/test1.sparql @prefix : <http://yosi.us/sparql#> . @prefix log: <http://www.w3.org/2000/10/swap/log#> . @prefix spa: <http://www.w3.org/2000/10/swap/sparqlCwm#> . @prefix test: <#> . @forAll :mbox, :x. @forSome test:_g0 . "file:/home/syosi/CVS-local/WWW/2000/10/swap/test/sparql/" spa:data test:_g0 . [ a spa:SelectQuery; spa:select {:mbox spa:bound "mbox" . }; spa:where {test:_g0 log:includes {:x <http://xmlns.com/foaf/0.1/mbox> :mbox; <http://xmlns.com/foaf/0.1/name> "Johnny Lee Outlaw" . } . } ]. { test:_g0 log:includes {:x <http://xmlns.com/foaf/0.1/mbox> :mbox; <http://xmlns.com/foaf/0.1/name> "Johnny Lee Outlaw" . } . } log:implies {{ :mbox spa:bound "mbox" . } a spa:Result . } . #ENDS [2] For instance: PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX : <http://example.com/here#> SELECT * WHERE {?x rdf:first :first } cwm assumes all graphs contain all lists, so it cowardly refuses to give infinite answers.
Received on Wednesday, 10 August 2005 18:47:22 UTC