Bare collections in Turtle and TriG

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 Sunday, 17 November 2013 17:49:33 UTC