W3C home > Mailing lists > Public > public-rdf-wg@w3.org > June 2012

Re: SPARQL and Turtle Prefix Placement

From: David Wood <david@3roundstones.com>
Date: Sat, 16 Jun 2012 09:11:12 -0400
Cc: Gavin Carothers <gavin@carothers.name>, W3C RDF WG <public-rdf-wg@w3.org>
Message-Id: <9974B1E9-2B1C-462E-9B66-785DF399CEF2@3roundstones.com>
To: Eric Prud'hommeaux <eric@w3.org>
On Jun 14, 2012, at 19:04, Eric Prud'hommeaux wrote:

> * David Wood <david@3roundstones.com> [2012-06-14 14:02-0400]
>> Hi Gavin and Eric (and everyone else),
>> 
>> I just noticed that the placement of the PREFIX names differ in the SPARQL and Turtle grammars:  Turtle allows prefixes to be anywhere, but SPARQL requires them to be at the top.
>> 
>> The relevant section from the Turtle grammar [1] is:
>> [[
>> [1]	turtleDoc		::=	(statement)*
>> [2]	statement		::=	(directive '.') | (triples '.')
>> [3]	directive		::=	prefixID | base
>> [4]	prefixID		::=	'@prefix' PNAME_NS IRIREF
>> [5]	base			::=	'@base' IRIREF
>> ]]
>> ...and the relevant section from the SPARQL 1.1 grammar [2] is:
>> [[
>> [1]  	QueryUnit	::=  	Query
>> [2]  	Query		::=  	Prologue
>> ( SelectQuery | ConstructQuery | DescribeQuery | AskQuery )
>> BindingsClause
>> ...
>> [4]  	Prologue		::=  	( BaseDecl | PrefixDecl )*
>> [5]  	BaseDecl		::=  	'BASE' IRI_REF
>> [6]  	PrefixDecl	::=  	'PREFIX' PNAME_NS IRI_REF
>> ]]
>> 
>> Should we align the two grammars so the prefixes must be at the top, as in SPARQL?  I tend to think so, in consideration of our ISSUE-1 [3].  The obvious downside would be a stricter requirement on Turtle authors to produce leading prefixes (which some in the wild don't currently).
>> 
>> The benefits would include easier reading and maintenance of the prefixes, as well as forced alignment with SPARQL's requirement in Section 19.5 that "A prefix declared with the PREFIX keyword may not be re-declared in the same query." [4]
> 
> I think it's more useful to have Turtle documents be concatenate-able.

I agree in principle, but wrote the above after dealing with a 5.5GB Turtle file this week with 29,669 prefixes, only 1,591 of which were unique.  The concatenation also resulted in a single prefix being re-defined to different values 178 times within the file.  In other words, the file was adequately pathological that it was difficult to work with, difficult to split and will be difficult to maintain.

Still, in the Unix philosophy of giving people enough rope to hang themselves, I can live with this as it stands.

Regards,
Dave


> The cost is that some Turtle will be tedious to copy to SPARQL, but I think it's worth the cost.
> 
> btw, i've been updating the grammar to deal with some LL(1).LALR(1) and other conflicts. should be synched soon.
> 
> 
>> Regards,
>> Dave
>> 
>> [1] http://dvcs.w3.org/hg/rdf/raw-file/default/rdf-turtle/index.html#sec-grammar-grammar
>> [2] http://www.w3.org/TR/sparql11-query/#grammar
>> [3] http://www.w3.org/2011/rdf-wg/track/issues/1
>> [4] http://www.w3.org/TR/sparql11-query/#iriRefs
>> 
>> 
> 
> -- 
> -ericP
Received on Saturday, 16 June 2012 13:11:41 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:25:49 GMT