W3C home > Mailing lists > Public > public-rdf-comments@w3.org > November 2013

Re: TriG examples not conforming to grammar

From: Gregg Kellogg <gregg@greggkellogg.net>
Date: Sun, 17 Nov 2013 14:00:19 -0800
Cc: public-rdf-comments Comments <public-rdf-comments@w3.org>
Message-Id: <F2C77F61-EFE3-414E-BD5F-1431A7C9F0D6@greggkellogg.net>
To: Richard Smith <richard@ex-parrot.com>
On Nov 17, 2013, at 10:25 AM, Richard Smith <richard@ex-parrot.com> wrote:

> 
> The TriG grammar [sect 4.5] does not permit a wrapped graph to end with a '.'.
> 
>  # Illegal
>  { :foo a foaf:Person . }
> 
>  # Legal
>  { :foo a foaf:Person }
> 
> However every single example in the 5 Nov candidate recommendation includes a wrapped graph ending with a '.'.
> 
> In SPARQL, the terminating '.' is not permitted, and it is only those sections of the examples that use the SPARQL 'GRAPH' syntax that conform to the TriG grammar.  For SPARQL compatibility is necessary to allow omission of the terminating '.' when the 'GRAPH' keyword is used.  The formula syntax of N3, from which the wrapped graph syntax is clearly derived, also does not permit a terminating '.'.
> 
> The simple solution is simply to update all examples to remove the terminating '.'.  The problem with this is until the draft of 19 Sept 2013, the terminating '.' was required and any early adopters are probably expecting to allow the terminating '.'.  Even now, a causal read of the candidate recommendation suggests that it is required (or at least allowed) because of the erroneous examples.  The terminating '.' is not marked as a "feature at risk".
> 
> An altenative would be to require the terminating '.' in the native (i.e. non-SPARQL) syntax, but to prohibit it in the SPARQL syntax.  This provides compatibility with the present examples and with SPARQL, and is easy enough to implement by providing two versions of wrappedGraph and triplesBlock, one with a terminating '.' and one without.  But this seems arbitrary and confusing.
> 
> Probably the best solution is to make the terminating '.' optional in all cases.  This would be easy fix to make by changing the triplesBlock production in the TriG grammar to read:
> 
>  [6g] triplesBlock ::= triples ('.' triplesBlock?)? '.'?

My reading of this rule, and the implementation of my own parser, makes both versions legal. Consider the following parsing sequence:

{ :foo a foaf:Person . } <= trigDoc => block => triplesOrGraph => wrappedGraph

:foo a foaf:Person . } <= triplesBlock? => triples ('.' triplesBlock?)?

. } <= ('.' triplesBlock?)? => '.' triplesBlock? => '.'

} <= end of wrappedGraph

Because the triplesBlock? is inside ('.' triplesBlock?) ? this means that a trailing dot is fine, or a trailing dot followed by another triplesBlock, or nothing at all.

Gregg

> Richard
> 
Received on Sunday, 17 November 2013 22:00:46 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:29:58 UTC