Re: Bare collections in Turtle and TriG

Richard,

Thank you for your comment regarding collections in Turtle and TriG. The 
Working Group agrees that it is desirable that Turtle and TriG be 
aligned here and the Working Group wishes to avoid:

() .

being a legal document.

There is a bug in the TriG grammar and the following change has been 
made to rule 4g of TriG to align Turtle and TriG.


[4g]     triples2     ::=
      (blankNodePropertyList | collection) predicateObjectList? '.'

==>

[4g]     triples2     ::=
      blankNodePropertyList predicateObjectList? '.'
         |
         collection predicateObjectList '.'

and tests have been added to the test suite to cover this.

A collection must be followed by a predicate-object-list as in Turtle.

This removes ( 1 2 3 ) . as a legal TriG document.  It also removes () . 
  as a legal document.  The 'collection' in TriG and Turtle rule allows 
the empty collection () which is no triples.

To go further and to keep alignment, requires significant changes to 
Turtle which the working group does not have the time to execute on even 
if there were general agreement it is desirable change to the language. 
  The issue of bare collections in Turtle has been discussed over the 
lifetime of the working group.

If this response is sufficient, please reply with "[RESOLVED]" in the 
subject line.

     Andy
     on behalf of the RDF Working Group
     (also involved in the development of the SPARQL Grammar)

On 18/11/13 10:24, Andy Seaborne wrote:
> Richard,
>
> Thank you for your comment.  I've recorded this as RDF WG Issue 173.
>
> https://www.w3.org/2011/rdf-wg/track/issues/173
>
> We'll get back to you as we can.
>
>      Andy
>
> On 17/11/13 17:49, Richard Smith wrote:
>>
>> The following is not a valid Turtle document, per the candidate
>> recommendation:
>>
>>    ( :foo :bar ) .
>>
>> This is because a collection can only appear as the subject of a
>> statement in Turtle.
>>
>> The same document is a valid TriG document as it matches the triples2
>> production in the grammar.
>>
>> It seems desirable that both TriG and Turtle should do the same thing
>> here, and in general that any valid TriG document that does not use the
>> { ... } construct should be a valid Turtle document.
>>
>> SPARQL 1.0 allows bare collections that are not the subject of a
>> statement, and that is now a stable recommendation.  It therefore seems
>> best to conform to that by allowing bare collections in both TriG and
>> Turtle.
>>
>>
>> In TriG, if it the collection is placed inside a wrapped graph in TriG,
>> it is no longer valid:
>>
>>    GRAPH { ( :foo :bar ) }
>>
>> This is directly incompatible with SPARQL 1.0, and for that reason
>> should be fixed.  It also introduces a surprising difference between
>> implicit and explicit use of the default graph.
>>
>>
>> Bare collections are potentially useful as they do generate RDF
>> statements.  So I think the right solution is to allow bare collections
>> in both languages, inside and outside of wrapped graphs.  The simplest
>> way of fixing this seems to me to be to redefine the following grammar
>> productions:
>>
>> Currently in Turtle:
>>
>>    [6]   triples     ::= subject predicateObjectList
>>                            | blankNodePropertyList predicateObjectList?
>>    [10]  subject     ::= iri | BlankNode | colection
>>
>>
>> Proposed in Turtle:
>>
>>    [6]   triples     ::= subject predicateObjectList
>>                            | triplesNode predicateObjectList?
>>    [10]  subject     ::= iri | BlankNode
>>    [NN]  triplesNode ::= blankNodePropertyList | collection
>>
>> The name 'triplesNode' is chosen because the corresponding grammar
>> production in SPARQL is called TriplesNode.
>>
>> The same change to the same grammar productions will fix TriG.  However
>> it may be desirable at the same time to:
>>
>>    1) change [4g] triples2 to reference the new triplesNode
>>       production;
>>
>>    2) delete production [7g] labelOrSubject and replace its
>>       use with subject, as the two are now identical; and
>>
>>    3) delete production [14] blank and expand its sole use
>>       in [12] object because (i) it has a misleading name,
>>       (ii) it causes the definition of object to differ
>>       (albeit cosmetically) between TriG and Turtle, and
>>       (iii) it is misnumbered (it should have a 'g' suffix)
>>       and throws out the correspondence between production
>>       numbers in Turtle and TriG.
>>
>>
>> Richard
>>
>

Received on Friday, 22 November 2013 10:05:41 UTC