- From: Seaborne, Andy <andy.seaborne@hp.com>
- Date: Fri, 05 Aug 2005 12:39:51 +0100
- To: Steve Harris <S.W.Harris@ecs.soton.ac.uk>
- CC: DAWG public list <public-rdf-dawg@w3.org>
Steve Harris wrote: > On Thu, Aug 04, 2005 at 07:25:45 +0100, Andy Seaborne wrote: > >>Steve Harris wrote: >> >>>On Thu, Aug 04, 2005 at 11:55:33 +0100, Andy Seaborne wrote: >>> >>> >>>>http://lists.w3.org/Archives/Public/public-rdf-dawg-comments/2005Aug/0038 >>>> >>>> >>>>Walid Maalej wrote: >>>> >>>> >>>>>Dear RDF Data Access Working Group Members, >>>>> >>>>>In the last working draft of the 21st. of July 2005, changes have been >>>> >>>>done >>>> >>>> >>>>>concerning the definition of the variable names within a SPARQL query. >>>>>The syntax is specified under >>>>>http://www.w3.org/TR/rdf-sparql-query/#rVARNAME . >>>>>I'm wondering if there is any reason not to allow the underscore "_" at >>>> >>>>the >>>> >>>> >>>>>Beginning of a variable name from the grammar point of view. >>>>>This could be very useful for application that build SPARQL queries >>>>>automatically and call the variables like the RDF:ID of the searched >>>>>resource. >>>> >>>>Allowing "_" as the first character of a VARNAME does not affect any >>>>approved tests and does not break the grammar in any way. I have added >>>>it. >>> >>> >>>No, but it does break my code. I was using _ as a reserved prefix for >>>internal and temporary variables. >> >>:-) >> >>And, of course, it used to be legal until the last WD. >> >>I use much the same trick: "=" for variables wot was bNodes and "#" for >>system variables like #now. > > > Its actually tricker than I thought, becasue it has to be a legal SQL > variable, but not a legal SPARQL variable, _ was very convienient. The > alternative you be to prefix all the sparql variables, which will make > the contrustions harder to read. > > As the comment was along the lines of "I was wondering why..." I would > prefer it if _ is not allowed at the start of variable names. > > - Steve > The motivation for the original request was that variables names should follow XML NCNAMEs (and they had been very close in previous drafts). While, in theory, we could use exactly NCNAMEs, the presence of '.' and '-' would be confusing (akin to '.' in qnames) a variable could be "?x-3". To look at what other systems do: -- In XQuery, variables are qnames. XML qnames don't necessarily have a : in them. http://www.w3.org/TR/xquery/#id-variables >> [Definition: A variable reference is a QName preceded by a $-sign.] -- MySQL user variables can contain '.', '_', and '$'. http://dev.mysql.com/doc/mysql/en/variables.html Because '.' and '$' definitely can't be in variables names that makes them safe. MySQL table and column names allow anything but '.' '\' and '/' http://dev.mysql.com/doc/mysql/en/legal-names.html which is pretty generous -- In SQL, identifiers aren't case sensitive (unless quoted) so the range of SPARQL variables and SQL variables isn't the same. I found http://www.postgresql.org/docs/8.0/static/sql-syntax.html#SQL-SYNTAX-IDENTIFIERS helpful. SQL (standard) identifiers can end in "$" or start "x$" Andy
Received on Friday, 5 August 2005 11:41:09 UTC