W3C home > Mailing lists > Public > public-rdf-dawg-comments@w3.org > September 2011

Grammar for PREFIX definitions

From: David Booth <david@dbooth.org>
Date: Mon, 12 Sep 2011 14:06:12 -0400
To: public-rdf-dawg-comments@w3.org
Message-ID: <1315850772.2882.52799.camel@dbooth-laptop>
It would be helpful to allow a prefix to be defined in terms of a
previously defined prefix, so that one could write a query like this:

  PREFIX testingGraph: <http://example/non-intuitive-URI/g147x2>
  PREFIX productionGraph: <http://example/non-intuitive-URI/g42m11>
  PREFIX graphToUse: testingGraph:

  INSERT ... GRAPH graphToUse: { ... }
  WHERE ... GRAPH graphToUse: { ... }

This way, to change the query from test to production use, one only
needs to change one prefix definition, and it is still very mnemonic:

  PREFIX graphToUse: productionGraph:

Without this ability, one would instead have to write something like the
following, which is far less mnemonic (because URIs are often not very
intuitive):

  PREFIX graphToUse: <http://example/non-intuitive-URI/g42m11>


This ability would also enable groups of related graph names to be
managed a little easier.  For example, a query might use three input
graphs and produce one output graph:

  PREFIX testBase: <http://example/test-URI-base/>
  PREFIX productionBase: <http://example/production-URI-base/>
  PREFIX graphBase: testBase:


  INSERT ... GRAPH graphBase:output { ... }
  WHERE ... GRAPH graphBase:input1 { ... }
        ... GRAPH graphBase:input2 { ... }
        ... GRAPH graphBase:input3 { ... }


However, at present the grammar for PREFIX definitions does not permit a
prefix to be defined in terms of a previously defined prefix: 
http://www.w3.org/TR/sparql11-query/#rPrefixDecl 

  [6]  PrefixDecl  ::=  'PREFIX' PNAME_NS IRI_REF

I suggest changing grammar rule 6 to:

  [6]  PrefixDecl  ::=  'PREFIX' PNAME_NS IRIref

This would allow the prefix to be defined in terms of either an IRI_REF
or a PrefixedName, per rule 125:

  [125]  IRIref	  ::=  	IRI_REF | PrefixedName



If the working group decides not to include this ability in SPARQL 1.1
(especially given how late this comment is arriving) then please put it
on a wish list for a future version.

Thanks!


-- 
David Booth, Ph.D.
http://dbooth.org/

Opinions expressed herein are those of the author and do not necessarily
reflect those of his employer.
Received on Monday, 12 September 2011 18:06:46 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 12 September 2011 18:06:47 GMT