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

Re: SPARQL and Turtle Prefix Placement

From: Andy Seaborne <andy.seaborne@epimorphics.com>
Date: Thu, 14 Jun 2012 21:49:44 +0100
Message-ID: <4FDA4E68.1010903@epimorphics.com>
To: public-rdf-wg@w3.org


On 14/06/12 21:24, Gregg Kellogg wrote:
>
>
> Gregg
>
> On Jun 14, 2012, at 11:02 AM, David Wood wrote:
>
>> 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.
>>
... (mangled)
>>
>> 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).
>
> I disagree, the needs for Turtle and SPARQL are different, even
> though the grammars are aligned. SPARQL documents tend to be much
> shorter, and appropriate for in-memory parsing and serializing.
>
> Turtle documents can be _much_ larger (I've seen test cases in the
> Giga-byte range). A streaming serializer may not know what prefixes
> are necessary when starting output, and may only discover this
> partway through processing. Allowing a @prefix to be defined here
> supports this case.
>
> It's also possible (modulo base IRI expansion) to process multiple
> Turtle documents by concatenating them together, which in some
> systems, can save some parser startup overhead.
>
> I've also seen usage (probably mostly from N3) where @base is
> repeated at different points to "reset" the base for relative IRI
> evaluation.
>
> I think we need to keep the current definition.

+1

SPARQL Query only allows the prefixes at the start.
But then you can't meaningfully concatenate two queries and queries have 
{} nesting.

(Aside to Ivan:
    GRAPH <U> { <s> <p> <o> GRAPH <V> { <s1> <p1> <o1> } }
means the quad is <V> <s1> <p1> <o1>. }

SPARQL Update does allow prefixes between update operations, and you can 
combine operate operations by concatenation (care about the ";" but 
mutliple ";" are safe and OK).

[29]  Update  ::=  Prologue ( Update1 ( ';' Update )? )?

so recursively, you can have multiple prologue (prefixes+base), which 
build on one another.

Turtle files can be concatenated as Gregg said.

	Andy


>
> Gregg
>
>> 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 20:50:15 GMT

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