Re: SPARQL: graph syntax should be N3 subset

Tim,

At the Boston face-to-face (Feb 28, March 1), the working group developed a set 
of possible changes to the SPARQL syntax using N3 or turtle like constructs for 
triple patterns.  The working group resolved at Tuesday's telecon to make those 
changes.  The proposal is outlined in:

http://lists.w3.org/Archives/Public/public-rdf-dawg/2005JanMar/0227.html

The editors' working draft has been updated (grammar and examples).  Full 
explanation of the syntax is still to be written up.

	Andy

Tim Berners-Lee wrote:
> Reading the 2004/10/13 draft of SPARQL.
> 
> The grammar for SPARQL frequently involves graph patterns.   These 
> should use the N3 grammar, specifically a subset at a level to the 
> subset known as Turtle.
> 
> There advantages to the languages overlapping.
> 
> - Cuts the learning curve for people learning SPARQL and N3.
> - Allows code sharing for those implementing both languages
> - Allows data to be searched for to be pasted into a query.
> - Allows one to create some example data, view it as N3, and then paste 
> it into the 'construct' clause, replacing a few values with variables.
> 
> N3 is a very suitable syntax for this:
> 
> - N3 has commonly used subsets Turtle and NTriples which are widely 
> deployed
> - N3 is a syntax which meets exactly the same goals as SPARQL, in being 
> concise and human-friendly representation of a graph with variables;
> - N3 has been used in the SPARQL document itself for readability for 
> the data.
> - N3 has evolved in response to community needs in the RDF Interest 
> Group and SW Interest Group.
> 
> N3 has come a long way since it started as a triples language:
> 
> - The comma and semicolon were added very early on a shortcuts making 
> both reading and writing easier when subject [and predicate] are 
> repeated.   While it is true that SPARQL's current individual triples 
> form is simpler, I strongly believe that the users would tired of it 
> once they become familiar with it.  (Similarly, the list construct for 
> collections makes it possible to actually use lists in practice, where 
> elaborations in terms of rdf:first and rdf:rest are impractically 
> cumbersome.)
> 
> - The grammar of the language is now defined in a context-free grammar 
> in RDF itself.
> 
> - Much of the actual nitty-gritty questions about the language involved 
> details of tokenizing, sets of characters allowed for identifiers, and 
> escaping.  The hassle comes from coordinating the XML, and N3 at the 
> NTriples, Turtle and N3 levels, and all the parsers involved.  To have 
> to add another randomly different language to this mix will make it 
> more difficult.
> 
> - The only significant change which has been proposed is to add syntax 
> for unordered sets similar to that for ordered collections.
> 
> 
> This is a strong suggestion.  I believe that the community will be best 
> served in making this change, and doing so as soon as possible.
> 
> It may be that at the same time we should plan for the standardization 
> of N3 itself, with spcific view to keeping Ntriples Turtle SqarQL and 
> N3 full in sync.
> 
> Tim Berners-Lee
> 
> 
> ___________________________________________
> PS:
> 
> If this is done, the N3 syntax could be extended to include the 
> keyword-style which the group seems to prefer for SPARQL. Assuming an 
> N3 semantics for SPARQL exists, then the sparql keywords could be 
> deemed to add extra syntactic shortcuts to the language.
> 
> @keywords select, from, where, prefix, option.
> 
> prefix   soc: <whatever>.
> select   ?x, ?y, ?z
> from     <mydata.rdf>
> where
> 	?x    a soc:Person;
> 		phone:number   "+1 781 555 1212";
> 		fam:sister	?y.
>         ?y   phone:number ?z.
> 
> Making SPARQL a subset of N3 would allow a SPARQL query to be quoted in 
> an N3 document, which would allow it to be carried as a payload in more 
> complex things, which might for example provide extra metadata about a 
> query.
> 
> 

Received on Friday, 11 March 2005 10:54:22 UTC