SPARQL syntax proposals

On Tuesday, the DAWG f2f took up syntax issues. We came up with a
syntax that was acceptable to all or most (don't know how SteveH would
phrase his feelings) of the attendees. These are expressed as examples
below. The principal change was in expressing the graph pattern in
"turtle+variables". Afterwords, Andy, Steve and I worked out how to
express regexps and not get an inscrutable grammar like perls.

We also changed AND to FILTER to express some constraints that we had
put on the effect of the value constraints section (namely that this
section ONLY restrict results, never add results or even, I think,
produce variables bindings).

These examples give a pretty good idea of our ideas:

simple query:
SELECT * WHERE { ?p ?s ?o }


which prefix:
PREFIX foaf: <http://example/foaf#>
SELECT ?me ?you
 WHERE { ?me foaf:knows ?you. ?you foaf:knows <fred> }

could also have either of these forms:
 WHERE { ?me rdf:type foaf:Person.} # trailing thingy in lexer
 WHERE { ?me rdf:type foaf:Person .} # parses same as above


ex with GRAPH and '.' in (but not ending) a QName.
 WHERE { GRAPH ?g  { ?g dc:source myPartOfUriSpace:foo.rdf } }
this is like turtle but n3 does not currenlty allow '.'s in names.


use the same syntax in the CONSTRUCT graph:
PREFIX foo: <http://www.w3.org/>
CONSTRUCT { ?s foo:bop ?o2 .
            ?o2 foo:bing ?o }
WHERE { ?s foo:bar ?o .
        ?o foo:baz ?o2 }

use turtle list syntax;
 WHERE { :bob :brothers (:joe :sam) }

use turtle ';' operator:
 WHERE { ?doc dc:title ?txt; dc:author ?who }
(good for symmetry even if not often used in queries.)

use turtle ',' operator:
 WHERE { ?who foaf:knows ?f1, ?f2 }.
(?who knows ?f1 and ?who knows ?f2.)

turtle has the 'a' operator (shortcut for rdf:type)
 WHERE { ?who a foaf:Person } # yes
but not other operators like '='.

bNodes are interpreted as unique, unreferencable variables.
SELECT ?who WHERE { ?who :brother [ in Army ], :mother [ in Navy] . }
(same as            ?who :brother ?b. 
                    ?b in Army.
                    ?who :mother ?m.
                    ?m in Navy              )

as promised, AND is now FILTER:
SELECT ?who
 WHERE { ?who :age ?n. FILTER ?n + 1 < 5 }


The promised the regexp syntax:

regexp(?x , "regexp"[, "flags"])
-- 
-eric

office: +81.466.49.1170 W3C, Keio Research Institute at SFC,
                        Shonan Fujisawa Campus, Keio University,
                        5322 Endo, Fujisawa, Kanagawa 252-8520
                        JAPAN
        +1.617.258.5741 NE43-344, MIT, Cambridge, MA 02144 USA
cell:   +81.90.6533.3882

(eric@w3.org)
Feel free to forward this message to any list for any purpose other than
email address distribution.

Received on Thursday, 3 March 2005 21:51:14 UTC