Skip to content

Commit e67bae6

Browse files
#314: Made focusNode an explicit param of exprEval, SPARQL-based expressions now pre-bind all scope vars (#370)
Closes #314 * #314: Made focusNode an explicit param of exprEval, SPARQL-based expressions now pre-bind all scope vars * #314: Fixes * #314: Clarified role of active graph * #314: active graph -> focus graph * Apply suggestions from code review Co-authored-by: Ted Thibodeau Jr <[email protected]> * Updated sh:expression to [ true ] list instead of "or" semantics --------- Co-authored-by: Ted Thibodeau Jr <[email protected]>
1 parent 0773d54 commit e67bae6

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

shacl12-core/index.html

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,7 @@ <h4>Node targets (sh:targetNode)</h4>
13591359
If <code>s</code> is a <a>shape</a> in a <a>shapes graph</a> <code>SG</code> and <code>s</code> has
13601360
<a>value</a> <code>expr</code> for <code>sh:targetNode</code> in <code>SG</code>,
13611361
then the <a>output nodes</a> of <code>expr</code> are <a>targets</a>
1362-
for the data graph <code>DG</code> as <a>active graph</a>.
1362+
for the data graph <code>DG</code> as <a>focus graph</a>.
13631363
</div>
13641364
<p><em>The remainder of this section is informative.</em></p>
13651365
<p>
@@ -2406,14 +2406,15 @@ <h2>Node Expressions</h2>
24062406
</div>
24072407
<div class="def" id="node-expression-evaluation">
24082408
<div class="def-header">EVALUATION OF NODE EXPRESSIONS</div>
2409-
The <dfn>evaluation</dfn> of a node expression is defined as a function <code>evalExpr(expr, activeGraph, scope) -> outputNodes</code>
2409+
The <dfn>evaluation</dfn> of a node expression is defined as a function <code>evalExpr(expr, focusGraph, focusNode, scope) -> outputNodes</code>
24102410
where
24112411
<ul>
24122412
<li><code>expr</code> is a <a>node expression</a> in a <a>shapes graph</a>.
24132413
During evaluation, the engine can access <a>triples</a> related to <code>expr</code> in the <a>shapes graph</a>.</li>
2414-
<li><code>activeGraph</code> is a <a>graph</a>, called the <dfn>active graph</dfn>.</li>
2414+
<li><code>focusGraph</code> is a <a>graph</a>, called the <dfn>focus graph</dfn>. This is the default query graph for the evaluation of the node expression.</li>
2415+
<li><code>focusNode</code> is a <a>node</a>, called the <dfn>input focus node</dfn>. This variable may have no value.</li>
24152416
<li><code>scope</code> is a map from <a href="https://www.w3.org/TR/sparql12-query/#defn_QueryVariable">variable names</a> to individual <a>nodes</a>.
2416-
The value of the variable <code>focusNode</code> (if it exists) is called the <dfn>input focus node</dfn>.
2417+
The empty map is written as <code>{}</code>.
24172418
</li>
24182419
</ul>
24192420
The result of the evaluation of a node expression is a list of <a>nodes</a> (possibly empty and with duplicates) called the <dfn>output nodes</dfn>.
@@ -2440,7 +2441,7 @@ <h3>IRI Expressions</h3>
24402441
The <a>output nodes</a> of an <a>IRI expression</a> are the list consisting of exactly the <a>node expression</a> itself:
24412442
<br/>
24422443
<br/>
2443-
<code>evalExpr(expr, activeGraph, scope) -> [expr]</code>
2444+
<code>evalExpr(expr, focusGraph, focusNode, scope) -> [expr]</code>
24442445
</p>
24452446
</div>
24462447
</section>
@@ -2459,7 +2460,7 @@ <h3>Literal Expressions</h3>
24592460
The <a>output nodes</a> of a <a>literal expression</a> are the list consisting of exactly the <a>node expression</a> itself:
24602461
<br/>
24612462
<br/>
2462-
<code>evalExpr(expr, activeGraph, scope) -> [expr]</code>
2463+
<code>evalExpr(expr, focusGraph, focusNode, scope) -> [expr]</code>
24632464
</p>
24642465
</div>
24652466
</section>
@@ -2919,13 +2920,11 @@ <h4>Value Nodes of Property Shapes</h4>
29192920
</li>
29202921
<li>
29212922
If <code>e</code> is the <a>value</a> of <code>sh:values</code> at the <a>property shape</a>,
2922-
then add the <a>output nodes</a> of <code>evalExpr(e, <a>data graph</a>, scope)</code> where <code>scope</code>
2923-
contains the <a>focus node</a> as the value of the variable <code>focusNode</code>.
2923+
then add the <a>output nodes</a> of <code>evalExpr(e, <a>data graph</a>, <a>focus node</a>, {})</code>.
29242924
</li>
29252925
<li>
29262926
If the set is still empty and <code>d</code> is the <a>value</a> of <code>sh:defaultValue</code> at the <a>property shape</a>,
2927-
then add the <a>output nodes</a> of <code>evalExpr(d, <a>data graph</a>, scope)</code> where <code>scope</code>
2928-
contains the <a>focus node</a> as the value of the variable <code>focusNode</code>.
2927+
then add the <a>output nodes</a> of <code>evalExpr(d, <a>data graph</a>, <a>focus node</a>, {})</code>.
29292928
</li>
29302929
</ol>
29312930
</section>
@@ -6003,7 +6002,7 @@ <h4>sh:expression</h4>
60036002
Based on <a>node expressions</a>, this section introduces a <a>constraint component</a> called
60046003
<dfn data-lt="expression constraint">expression constraints</dfn>.
60056004
Expression constraints can be used in any <a>shape</a> to declare the condition that the
6006-
<a>node expression</a> specified via <code>sh:expression</code> has <code>true</code> as one of its output nodes.
6005+
<a>node expression</a> specified via <code>sh:expression</code> has <code>true</code> as its only output node.
60076006
The evaluation of these node expressions is repeated for all <a>value nodes</a> of the <a>shape</a>
60086007
as the <a>focus node</a>.
60096008
</p>
@@ -6031,9 +6030,8 @@ <h4>sh:expression</h4>
60316030
<div class="def-text-body" data-validator="Expression">
60326031
Let <code>expr</code> be the <a>value</a> of <code>sh:expression</code>.
60336032
For each <a>value node</a> <code>v</code>
6034-
and <code>scope</code> contains <code>v</code> as the value of <code>focusNode</code>
6035-
where <code>evalExpr(expr, activeGraph, scope)</code>
6036-
does not return <code>true</code> as one of its <a>output nodes</a>,
6033+
where <code>evalExpr(expr, <a>data graph</a>>, v, {})</code>
6034+
does not return the list consisting of exactly <code>true</code> as its <a>output nodes</a>,
60376035
there is a <a>validation result</a> that has <code>v</code> as its <code>sh:value</code>
60386036
and a <a>deep copy</a> of <code>expr</code> in the results graph as its <code>sh:sourceConstraint</code>.
60396037
If the <code>expr</code> has <a>values</a> for <code>sh:message</code> in the <a>shapes graph</a>,

shacl12-sparql/index.html

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ <h3>Terminology</h3>
408408
<dfn data-cite="shacl12-core#dfn-function-name" data-lt="node expression function name">function name</dfn>,
409409
<dfn data-cite="shacl12-core#dfn-key-parameter" data-lt="key parameter">key parameter</dfn>,
410410
<dfn data-cite="shacl12-core#dfn-output-nodes" data-lt="output nodes">output nodes</dfn>,
411+
<dfn data-cite="shacl12-core#dfn-focus-graph" data-lt="focus graph">focus graph</dfn>,
411412
<dfn data-cite="shacl12-core#dfn-conform" data-lt="conform|conforms">conform</dfn>,
412413
<dfn data-cite="shacl12-core#dfn-failure" data-lt="failure|failures">failure</dfn>,
413414
<dfn data-cite="shacl12-core#dfn-shacl-instance" data-lt="shacl instance">SHACL instance</dfn>,
@@ -1229,11 +1230,13 @@ <h3>Select Expressions</h3>
12291230
<div class="def-header">EVALUATION OF SELECT EXPRESSIONS</div>
12301231
<p>
12311232
The <a>output nodes</a> of a <a>select expression</a> are the list <code>resultNodes</code> consisting of exactly the bindings of the (only)
1232-
variable that is projected from the SELECT clause.
1233-
If present in the <a>scope</a>, the value of the scope variable <code>focusNode</code> MUST be <a>pre-bound</a> as the value of the SPARQL variable <code>this</code>.
1233+
variable that is projected from the <code>SELECT</code> clause when the query is evaluated against the <a>focus graph</a>.
1234+
The value of <code>focusNode</code> is <a>pre-bound</a> as the value of the SPARQL variable <code>this</code>.
1235+
The value of each scope variable is <a>pre-bound</a> as a SPARQL variable with the same name and value.
1236+
A <a>failure</a> is produced when one of the scope variables is called <code>this</code>.
12341237
<br/>
12351238
<br/>
1236-
<code>evalExpr(expr, activeGraph, scope) -> resultNodes</code>
1239+
<code>evalExpr(expr, focusGraph, focusNode, scope) -> resultNodes</code>
12371240
</p>
12381241
</div>
12391242
<p><em>The remainder of this section is informative.</em></p>
@@ -1340,11 +1343,14 @@ <h3>SPARQL Expr Expressions</h3>
13401343
<div class="def-header">EVALUATION OF SPARQL EXPR EXPRESSIONS</div>
13411344
<p>
13421345
The <a>output nodes</a> of an <a>SPARQL expr expression</a> are the list <code>resultNodes</code> consisting of exactly the bindings of the (only)
1343-
variable that is projected from the SELECT clause of the <code>select</code> query as defined <a href="#syntax-rule-SPARQLExprExpression-template">above</a>.
1344-
If present in the <a>scope</a>, the value of the scope variable <code>focusNode</code> MUST be <a>pre-bound</a> as the value of the SPARQL variable <code>this</code>.
1346+
variable that is projected from the <code>SELECT</code> clause of the <code>select</code> query as defined <a href="#syntax-rule-SPARQLExprExpression-template">above</a>
1347+
when the query is evaluated against the <a>focus graph</a>.
1348+
The value of <code>focusNode</code> is <a>pre-bound</a> as the value of the SPARQL variable <code>this</code>.
1349+
The value of each scope variable is <a>pre-bound</a> as a SPARQL variable with the same name and value.
1350+
A <a>failure</a> is produced when one of the scope variables is called <code>this</code>.
13451351
<br/>
13461352
<br/>
1347-
<code>evalExpr(expr, activeGraph, scope) -> resultNodes</code>
1353+
<code>evalExpr(expr, focusGraph, focusNode, scope) -> resultNodes</code>
13481354
</p>
13491355
</div>
13501356
<p><em>The remainder of this section is informative.</em></p>

0 commit comments

Comments
 (0)