@@ -8730,10 +8730,10 @@ <h4>Variable Scope</h4>
8730
8730
query. The definition below provides a way of determining this from the
8731
8731
abstract syntax tree of a query.</p>
8732
8732
<p>Note that a subquery with a projection can hide variables; use of a variable in
8733
- <code> FILTER</code> or in <code> MINUS</code> does not cause the variable to be in-scope
8733
+ ` FILTER` or in ` MINUS` does not cause the variable to be in-scope
8734
8734
outside of those forms.</p>
8735
8735
<p>Let <b>P</b>, <b>P1</b>, and <b>P2</b> be graph patterns, and <b>E</b>,
8736
- <b>E1</b>,..., through <b>En</b> be expressions. A variable <code>v</code> is in-scope if:</p>
8736
+ <b>E1</b>,..., through <b>En</b> be expressions. A variable `v` is in-scope if:</p>
8737
8737
<table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
8738
8738
<tbody>
8739
8739
<tr>
@@ -8742,70 +8742,81 @@ <h4>Variable Scope</h4>
8742
8742
</tr>
8743
8743
<tr>
8744
8744
<td>Basic Graph Pattern (BGP)</td>
8745
- <td><code>v</code> occurs in the BGP</td>
8745
+ <td>`v` occurs in the BGP</td>
8746
8746
</tr>
8747
8747
<tr>
8748
8748
<td>Path</td>
8749
- <td><code>v</code> occurs in the path</td>
8749
+ <td>`v` occurs in the path</td>
8750
8750
</tr>
8751
8751
<tr>
8752
- <td>Group <code> { P1 P2 ... }</code> </td>
8753
- <td><code>v</code> is in-scope if it is in-scope in one or more of P1, P2, ...</td>
8752
+ <td>Group ` { P1 P2 ... }` </td>
8753
+ <td>`v` is in-scope if it is in-scope in one or more of P1, P2, ...</td>
8754
8754
</tr>
8755
8755
<tr>
8756
- <td><code> GRAPH term { P }</code> </td>
8757
- <td><code>v</code> is <code> term</code> or <code>v</code> is in-scope in P</td>
8756
+ <td>` GRAPH term { P }` </td>
8757
+ <td>`v` is ` term` or `v` is in-scope in P</td>
8758
8758
</tr>
8759
8759
<tr>
8760
- <td><code> { P1 } UNION { P2 }</code> </td>
8761
- <td><code>v</code> is in-scope in P1 or in-scope in P2</td>
8760
+ <td>` { P1 } UNION { P2 }` </td>
8761
+ <td>`v` is in-scope in P1 or in-scope in P2</td>
8762
8762
</tr>
8763
8763
<tr>
8764
- <td><code> OPTIONAL {P}</code> </td>
8765
- <td><code>v</code> is in-scope in P</td>
8764
+ <td>` OPTIONAL {P}` </td>
8765
+ <td>`v` is in-scope in P</td>
8766
8766
</tr>
8767
8767
<tr>
8768
- <td><code> SERVICE term {P}</code> </td>
8769
- <td><code>v</code> is <code> term</code> or <code>v</code> is in-scope in P</td>
8768
+ <td>` SERVICE term {P}` </td>
8769
+ <td>`v` is ` term` or `v` is in-scope in P</td>
8770
8770
</tr>
8771
8771
<tr>
8772
- <td><code> BIND (expr AS v)</code> </td>
8773
- <td><code>v</code> is in-scope</td>
8772
+ <td>` BIND (expr AS v)` </td>
8773
+ <td>`v` is in-scope</td>
8774
8774
</tr>
8775
8775
<tr>
8776
- <td><code> SELECT .. v .. { P }</code> </td>
8777
- <td><code>v</code> is in-scope</td>
8776
+ <td>` SELECT .. v .. { P }` </td>
8777
+ <td>`v` is in-scope</td>
8778
8778
</tr>
8779
8779
<tr>
8780
- <td><code> SELECT ... (expr AS v)</code> </td>
8781
- <td><code>v</code> is in-scope</td>
8780
+ <td>` SELECT ... (expr AS v)` </td>
8781
+ <td>`v` is in-scope</td>
8782
8782
</tr>
8783
8783
<tr>
8784
- <td><code> GROUP BY (expr AS v)</code> </td>
8785
- <td><code>v</code> is in-scope</td>
8784
+ <td>` GROUP BY (expr AS v)` </td>
8785
+ <td>`v` is in-scope</td>
8786
8786
</tr>
8787
8787
<tr>
8788
- <td><code> SELECT * { P }</code> </td>
8789
- <td><code>v</code> is in-scope in <code>P</code> </td>
8788
+ <td>` SELECT * { P }` </td>
8789
+ <td>`v` is in-scope in `P` </td>
8790
8790
</tr>
8791
8791
<tr>
8792
- <td><code> VALUES v { values }</code> </td>
8793
- <td><code>v</code> is in-scope</td>
8792
+ <td>` VALUES v { values }` </td>
8793
+ <td>`v` is in-scope</td>
8794
8794
</tr>
8795
8795
<tr>
8796
- <td><code>VALUES varlist { values }</code></td>
8797
- <td><code>v</code> is in-scope if <code>v</code> is in <code>varlist</code></td>
8796
+ <td>`VALUES varlist { values }`</td>
8797
+ <td>`v` is in-scope if `v` is in `varlist`</td>
8798
+ </tr>
8799
+ <tr>
8800
+ <td>`EXISTS` and `NOT EXISTS`</td>
8801
+ <td>
8802
+ `v` is in-scope if it is in-scope for the
8803
+ <a href="#defn_sparqlSolutionMapping">solution mapping</a>
8804
+ where the expression containing `EXISTS` or `NOT EXISTS` is applied.
8805
+ </td>
8798
8806
</tr>
8799
8807
</tbody>
8800
8808
</table>
8801
- <p>The variable <code>v</code> must not be in-scope at the point of the <code>(expr AS
8802
- v)</code> form. The scoping for <code>(expr AS v)</code> applies immediately in
8803
- <code>SELECT</code> expressions.</p>
8804
- <p>In <code>BIND (expr AS v)</code> requires that the variable <code>v</code> is not
8805
- in-scope from the preceeding elements in the group graph pattern in which it is used.</p>
8806
- <p>In <code>SELECT</code>, the variable <code>v</code> must not be in-scope in the graph
8807
- pattern of the <code>SELECT</code> clause, nor used in another select expression earlier in
8808
- the clause.</p>
8809
+ <p>The variable `v` must not be in-scope at the point of the
8810
+ `(expr AS v)` form. The scoping for `(expr AS v)`
8811
+ applies immediately in `SELECT` expressions.
8812
+ </p>
8813
+ <p>In `BIND (expr AS v)` requires that the variable `v` is not
8814
+ in-scope from the preceeding elements in the group graph pattern in which it is used.
8815
+ </p>
8816
+ <p>In `SELECT`, the variable `v` must not be in-scope in the graph
8817
+ pattern of the `SELECT` clause, nor used in another select expression earlier in
8818
+ the clause.
8819
+ </p>
8809
8820
</section>
8810
8821
<section id="convertGraphPattern">
8811
8822
<h4>Converting Graph Patterns</h4>
@@ -10971,52 +10982,95 @@ <h3>Grammar</h3>
10971
10982
section 6 <a data-cite="xml11#sec-notation">Notation</a>.</p>
10972
10983
<p>Notes:</p>
10973
10984
<ol>
10974
- <li>Keywords are matched in a case-insensitive manner with the exception of
10975
- the keyword '<code>a</code>' which, in line with Turtle and N3, is used
10976
- in place of the IRI <code>rdf:type</code>
10977
- (in full, <code><a href="http://www.w3.org/1999/02/22-rdf-syntax-ns#type">http://www.w3.org/1999/02/22-rdf-syntax-ns#type</a></code>).</li>
10978
- <li>Escape sequences are case sensitive.</li>
10979
- <li>When tokenizing the input and choosing grammar rules, the longest match is chosen.</li>
10980
- <li>The SPARQL grammar is LL(1) when the rules with uppercased names are used as terminals.</li>
10981
- <li>There are two entry points into the grammar: <code>QueryUnit</code> for the SPARQL query language
10982
- and <code>UpdateUnit</code> for the SPARQL update language.</li>
10983
- <li>In signed numbers, no white space is allowed between the sign and the number.
10985
+ <li>
10986
+ Keywords are matched in a case-insensitive manner with the exception of
10987
+ the keyword '`a`' which, in line with Turtle and N3, is used
10988
+ in place of the IRI `rdf:type` (in full,
10989
+ <code><a href="http://www.w3.org/1999/02/22-rdf-syntax-ns#type">http://www.w3.org/1999/02/22-rdf-syntax-ns#type</a></code>).
10990
+ </li>
10991
+ <li>
10992
+ Escape sequences are case sensitive.
10993
+ </li>
10994
+ <li>
10995
+ When tokenizing the input and choosing grammar rules, the longest match is chosen.
10996
+ </li>
10997
+ <li>
10998
+ The SPARQL grammar is LL(1) when the rules with uppercased names are used as terminals.
10999
+ </li>
11000
+ <li>
11001
+ There are two entry points into the grammar: `QueryUnit` for the SPARQL query language
11002
+ and `UpdateUnit` for the SPARQL update language.
11003
+ </li>
11004
+ <li>
11005
+ In signed numbers, no white space is allowed between the sign and the number.
10984
11006
The <code><a href="#rAdditiveExpression">AdditiveExpression</a></code> grammar rule allows for this by
10985
11007
covering the two cases of an expression followed by a signed number. These
10986
- produce an addition or subtraction of the unsigned number as appropriate.</li>
10987
- <li>The tokens <code><a href="#rInsertData">INSERT DATA</a></code>,
11008
+ produce an addition or subtraction of the unsigned number as appropriate.
11009
+ </li>
11010
+ <li>
11011
+ The tokens <code><a href="#rInsertData">INSERT DATA</a></code>,
10988
11012
<code><a href="#rDeleteData">DELETE DATA</a></code> and
10989
11013
<code><a href="#rDeleteWhere">DELETE WHERE</a></code> allow any amount of white space between the words.
10990
- The single space version is used in the grammar for clarity.</li>
10991
- <li>The <code><a href="#rQuadData">QuadData</a></code> and
11014
+ The single space version is used in the grammar for clarity.
11015
+ </li>
11016
+ <li>
11017
+ The <code><a href="#rQuadData">QuadData</a></code> and
10992
11018
<code><a href="#rQuadPattern">QuadPattern</a></code>
10993
11019
rules both use rule <code><a href="#rQuads">Quads</a></code>. The rule
10994
11020
<code><a href="#rQuadData">QuadData</a></code>, used in
10995
11021
<a href="#rInsertData"><code>INSERTDATA</code></a> and
10996
11022
<a href="#rDeleteData"><code>DELETE DATA</code></a>,
10997
- must not allow variables in the quad patterns.</li>
10998
- <li>Blank node syntax is not allowed in <code><a href="#rDeleteWhere">DELETE WHERE</a></code>,
10999
- the <code><a href="#rDeleteClause">DeleteClause</a></code> for
11000
- <code>DELETE</code>,
11001
- nor in <code><a href="#rDeleteData">DELETE DATA</a></code>.</li>
11002
- <li>Rules for limiting the use of blank node identifiers are given in <a href="#grammarBNodes">section 19.6</a>.</li>
11003
- <li>The number of variables in the variable list of <code>VALUES</code> block
11004
- must be the same as the number of each list of associated values in the <code>DataBlock</code>.</li>
11005
- <li>Variables introduced by <code>AS</code> in a <code>SELECT</code> clause
11006
- must not already be <a href="#variableScope">in-scope</a>.</li>
11007
- <li>The variable assigned in a <code>BIND</code> clause must not be already
11023
+ must not allow variables in the quad patterns.
11024
+ </li>
11025
+ <li>
11026
+ Blank node syntax is not allowed in
11027
+ <code><a href="#rDeleteWhere">DELETE WHERE</a></code>,
11028
+ in a <code><a href="#rDeleteClause">DeleteClause</a></code>,
11029
+ or in <code><a href="#rDeleteData">DELETE DATA</a></code>.
11030
+ </li>
11031
+ <li>
11032
+ Rules for limiting the use of blank node identifiers are given in
11033
+ <a href="#grammarBNodes">section 19.6</a>.
11034
+ </li>
11035
+ <li>
11036
+ The number of variables in the variable list of <code>VALUES</code> block
11037
+ must be the same as the number of each list of associated values in the
11038
+ <code>DataBlock</code>.
11039
+ </li>
11040
+ <li>
11041
+ Variables introduced by <code>AS</code> in a <code>SELECT</code> clause
11042
+ must not already be <a href="#variableScope">in-scope</a>.
11043
+ </li>
11044
+ <li>
11045
+ The variable assigned in a <code>BIND</code> clause must not be already
11008
11046
in-use within the immediately preceding <code><a href="#rTriplesBlock">TriplesBlock</a></code> within a
11009
- <code><a href="#rGroupGraphPattern">GroupGraphPattern</a></code>.</li>
11010
- <li>Aggregate functions can be one of the
11047
+ <code><a href="#rGroupGraphPattern">GroupGraphPattern</a></code>.
11048
+ </li>
11049
+ <li>
11050
+ Aggregate functions can be one of the
11011
11051
<a href="#rAggregate">built-in keywords for aggregates</a>
11012
- or a custom aggregate, which is syntactically a <a href="#rFunctionCall">function
11013
- call</a>. Aggregate functions may only be used in
11052
+ or a custom aggregate, which is syntactically a
11053
+ <a href="#rFunctionCall">function call</a>.
11054
+ Aggregate functions may only be used in
11014
11055
<a href="#rSelectClause">SELECT</a>, <a href="#rHavingClause">HAVING</a>
11015
- and <a href="#rOrderClause">ORDER BY</a> clauses.</li>
11016
- <li>The expression argument of an aggregate function can not contain an aggregate function.</li>
11017
- <li>Only custom aggregate functions use the <code>DISTINCT</code> keyword
11018
- in a <a href="#rFunctionCall">function call</a>.</li>
11019
- <li>A <a href="#rReifier">reifier</a> or
11056
+ and <a href="#rOrderClause">ORDER BY</a> clauses.
11057
+ </li>
11058
+ <li>
11059
+ Any variable that is assigned to in the graph pattern of `EXISTS` or `NOT EXISTS`
11060
+ must not be <a href="#variableScope">in-scope</a>. This applies to `BIND`,
11061
+ variables introduced by `AS` in a `SELECT` clause,
11062
+ variables introduced by `AS` in `GROUP BY`,
11063
+ and variables in a `VALUES` clause.
11064
+ </li>
11065
+ <li>
11066
+ The expression argument of an aggregate function can not contain an aggregate function.
11067
+ </li>
11068
+ <li>
11069
+ Only custom aggregate functions use the <code>DISTINCT</code> keyword
11070
+ in a <a href="#rFunctionCall">function call</a>.
11071
+ </li>
11072
+ <li>
11073
+ A <a href="#rReifier">reifier</a> or
11020
11074
<a href="#rAnnotationBlockPath">annotation syntax</a>
11021
11075
is only permitted after a triple when the property position is
11022
11076
a simple path (an IRI, the keyword <code>a</code>, or a variable),
0 commit comments