From b983250307ebffb501384d821a8aa7112aa114a2 Mon Sep 17 00:00:00 2001
From: Andy Seaborne Variable Scope
query. The definition below provides a way of determining this from the
abstract syntax tree of a query.
Note that a subquery with a projection can hide variables; use of a variable in
- FILTER or in MINUS does not cause the variable to be in-scope
+ `FILTER` or in `MINUS` does not cause the variable to be in-scope
outside of those forms.
Let P, P1, and P2 be graph patterns, and E,
- E1,..., through En be expressions. A variable v is in-scope if:
| Basic Graph Pattern (BGP) | -v occurs in the BGP |
+ `v` occurs in the BGP | |
| Path | -v occurs in the path |
+ `v` occurs in the path | |
Group { P1 P2 ... } |
- v is in-scope if it is in-scope in one or more of P1, P2, ... |
+ Group `{ P1 P2 ... }` | +`v` is in-scope if it is in-scope in one or more of P1, P2, ... |
GRAPH term { P } |
- v is term or v is in-scope in P |
+ `GRAPH term { P }` | +`v` is `term` or `v` is in-scope in P |
{ P1 } UNION { P2 } |
- v is in-scope in P1 or in-scope in P2 |
+ `{ P1 } UNION { P2 }` | +`v` is in-scope in P1 or in-scope in P2 |
OPTIONAL {P} |
- v is in-scope in P |
+ `OPTIONAL {P}` | +`v` is in-scope in P |
SERVICE term {P} |
- v is term or v is in-scope in P |
+ `SERVICE term {P}` | +`v` is `term` or `v` is in-scope in P |
BIND (expr AS v) |
- v is in-scope |
+ `BIND (expr AS v)` | +`v` is in-scope |
SELECT .. v .. { P } |
- v is in-scope |
+ `SELECT .. v .. { P }` | +`v` is in-scope |
SELECT ... (expr AS v) |
- v is in-scope |
+ `SELECT ... (expr AS v)` | +`v` is in-scope |
GROUP BY (expr AS v) |
- v is in-scope |
+ `GROUP BY (expr AS v)` | +`v` is in-scope |
SELECT * { P } |
- v is in-scope in P |
+ `SELECT * { P }` | +`v` is in-scope in `P` |
VALUES v { values } |
- v is in-scope |
+ `VALUES v { values }` | +`v` is in-scope |
VALUES varlist { values } |
- v is in-scope if v is in varlist |
+ `VALUES varlist { values }` | +`v` is in-scope if `v` is in `varlist` | +
| `EXISTS` and `NOT EXISTS` | ++ `v` is in-scope if it is in-scope for the + solution mapping + where the expression containing `EXISTS` or `NOT EXISTS` is applied. + |
The variable v must not be in-scope at the point of the (expr AS
- v) form. The scoping for (expr AS v) applies immediately in
- SELECT expressions.
In BIND (expr AS v) requires that the variable v is not
- in-scope from the preceeding elements in the group graph pattern in which it is used.
In SELECT, the variable v must not be in-scope in the graph
- pattern of the SELECT clause, nor used in another select expression earlier in
- the clause.
The variable `v` must not be in-scope at the point of the + `(expr AS v)` form. The scoping for `(expr AS v)` + applies immediately in `SELECT` expressions. +
+In `BIND (expr AS v)` requires that the variable `v` is not + in-scope from the preceeding elements in the group graph pattern in which it is used. +
+In `SELECT`, the variable `v` must not be in-scope in the graph + pattern of the `SELECT` clause, nor used in another select expression earlier in + the clause. +
Notes:
a' which, in line with Turtle and N3, is used
- in place of the IRI rdf:type
- (in full, http://www.w3.org/1999/02/22-rdf-syntax-ns#type).QueryUnit for the SPARQL query language
- and UpdateUnit for the SPARQL update language.http://www.w3.org/1999/02/22-rdf-syntax-ns#type).
+ AdditiveExpression grammar rule allows for this by
covering the two cases of an expression followed by a signed number. These
- produce an addition or subtraction of the unsigned number as appropriate.INSERT DATA,
+ produce an addition or subtraction of the unsigned number as appropriate.
+ INSERT DATA,
DELETE DATA and
DELETE WHERE allow any amount of white space between the words.
- The single space version is used in the grammar for clarity.QuadData and
+ The single space version is used in the grammar for clarity.
+ QuadData and
QuadPattern
rules both use rule Quads. The rule
QuadData, used in
INSERTDATA and
DELETE DATA,
- must not allow variables in the quad patterns.DELETE WHERE,
- the DeleteClause for
- DELETE,
- nor in DELETE DATA.VALUES block
- must be the same as the number of each list of associated values in the DataBlock.AS in a SELECT clause
- must not already be in-scope.BIND clause must not be already
+ must not allow variables in the quad patterns.
+ DELETE WHERE,
+ in a DeleteClause,
+ nor in DELETE DATA.
+ VALUES block
+ must be the same as the number of each list of associated values in the
+ DataBlock.
+ AS in a SELECT clause
+ must not already be in-scope.
+ BIND clause must not be already
in-use within the immediately preceding TriplesBlock within a
- GroupGraphPattern.GroupGraphPattern.
+ DISTINCT keyword
- in a function call.DISTINCT keyword
+ in a function call.
+ a, or a variable),