Re: SPARQL and Turtle Prefix Placement

* 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. 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 Thursday, 14 June 2012 23:05:25 UTC