@@ -8730,10 +8730,10 @@ <h4>Variable Scope</h4>
87308730 query. The definition below provides a way of determining this from the
87318731 abstract syntax tree of a query.</p>
87328732 <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
87348734 outside of those forms.</p>
87358735 <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>
87378737 <table style="border-collapse: collapse; border-color: #000000; border-spacing:5px; border-width: 1px">
87388738 <tbody>
87398739 <tr>
@@ -8742,70 +8742,81 @@ <h4>Variable Scope</h4>
87428742 </tr>
87438743 <tr>
87448744 <td>Basic Graph Pattern (BGP)</td>
8745- <td><code>v</code> occurs in the BGP</td>
8745+ <td>`v` occurs in the BGP</td>
87468746 </tr>
87478747 <tr>
87488748 <td>Path</td>
8749- <td><code>v</code> occurs in the path</td>
8749+ <td>`v` occurs in the path</td>
87508750 </tr>
87518751 <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>
87548754 </tr>
87558755 <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>
87588758 </tr>
87598759 <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>
87628762 </tr>
87638763 <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>
87668766 </tr>
87678767 <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>
87708770 </tr>
87718771 <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>
87748774 </tr>
87758775 <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>
87788778 </tr>
87798779 <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>
87828782 </tr>
87838783 <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>
87868786 </tr>
87878787 <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>
87908790 </tr>
87918791 <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>
87948794 </tr>
87958795 <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>
87988806 </tr>
87998807 </tbody>
88008808 </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>
88098820 </section>
88108821 <section id="convertGraphPattern">
88118822 <h4>Converting Graph Patterns</h4>
@@ -10971,52 +10982,95 @@ <h3>Grammar</h3>
1097110982 section 6 <a data-cite="xml11#sec-notation">Notation</a>.</p>
1097210983 <p>Notes:</p>
1097310984 <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.
1098411006 The <code><a href="#rAdditiveExpression">AdditiveExpression</a></code> grammar rule allows for this by
1098511007 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>,
1098811012 <code><a href="#rDeleteData">DELETE DATA</a></code> and
1098911013 <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
1099211018 <code><a href="#rQuadPattern">QuadPattern</a></code>
1099311019 rules both use rule <code><a href="#rQuads">Quads</a></code>. The rule
1099411020 <code><a href="#rQuadData">QuadData</a></code>, used in
1099511021 <a href="#rInsertData"><code>INSERTDATA</code></a> and
1099611022 <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
1100811046 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
1101111051 <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
1101411055 <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
1102011074 <a href="#rAnnotationBlockPath">annotation syntax</a>
1102111075 is only permitted after a triple when the property position is
1102211076 a simple path (an IRI, the keyword <code>a</code>, or a variable),
0 commit comments