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

SPARQL and Turtle Prefix Placement

From: David Wood <david@3roundstones.com>
Date: Thu, 14 Jun 2012 14:02:30 -0400
Message-Id: <82BA6439-7B85-4619-9921-578A1FE9157A@3roundstones.com>
Cc: W3C RDF WG <public-rdf-wg@w3.org>
To: Gavin Carothers <gavin@carothers.name>, Eric Prud'hommeaux <eric@w3.org>
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]

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
Received on Thursday, 14 June 2012 18:03:00 GMT

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