|
84 | 84 | w3cid: 58399
|
85 | 85 | }
|
86 | 86 | ],
|
87 |
| - testSuiteURI: "http://w3c.github.io/data-shapes/data-shapes-test-suite/", |
| 87 | + testSuiteURI: "https://w3c.github.io/data-shapes/data-shapes-test-suite/", |
88 | 88 |
|
89 | 89 | previousPublishDate: "2017-07-20",
|
90 | 90 | previousMaturity: "REC",
|
@@ -383,6 +383,7 @@ <h3>Terminology</h3>
|
383 | 383 | <dfn data-cite="rdf12-concepts#dfn-literal" data-lt="literal|literals">literal</dfn>,
|
384 | 384 | <dfn data-cite="rdf12-concepts#dfn-blank-node" data-lt="blank node|blank nodes">blank node</dfn>,
|
385 | 385 | <dfn data-cite="rdf12-concepts#dfn-node" data-lt="node|nodes">node</dfn> of an RDF graph,
|
| 386 | + <dfn data-cite="rdf12-concepts#dfn-datatype" data-lt="datatype|datatypes">datatype</dfn>, |
386 | 387 | <dfn data-cite="rdf12-concepts#dfn-rdf-term" data-lt="term|terms">RDF term</dfn>, and
|
387 | 388 | <dfn data-cite="rdf12-concepts#dfn-subject" data-lt="subject|subjects">subject</dfn>,
|
388 | 389 | <dfn data-cite="rdf12-concepts#dfn-predicate" data-lt="predicate|predicates">predicate</dfn>, and
|
@@ -410,6 +411,11 @@ <h3>Terminology</h3>
|
410 | 411 | <dfn data-cite="shacl12-core#dfn-shapes-graph" data-lt="shapes graph">shapes graph</dfn>,
|
411 | 412 | <dfn data-cite="shacl12-core#dfn-target" data-lt="target|targets">target</dfn>,
|
412 | 413 | <dfn data-cite="shacl12-core#dfn-validators" data-lt="validator|validators">validator</dfn>,
|
| 414 | + <dfn data-cite="shacl12-core#dfn-node-expression" data-lt="node expression|node expresssions">node expression</dfn>, |
| 415 | + <dfn data-cite="shacl12-core#dfn-node-expression-function" data-lt="node expression function|node expresssion functions">node expression function</dfn>, |
| 416 | + <dfn data-cite="shacl12-core#dfn-function-name" data-lt="node expression function name">function name</dfn>, |
| 417 | + <dfn data-cite="shacl12-core#dfn-key-parameter" data-lt="key parameter">key parameter</dfn>, |
| 418 | + <dfn data-cite="shacl12-core#dfn-output-nodes" data-lt="output nodes">output nodes</dfn>, |
413 | 419 | <dfn data-cite="shacl12-core#dfn-conform" data-lt="conform|conforms">conform</dfn>,
|
414 | 420 | <dfn data-cite="shacl12-core#dfn-failure" data-lt="failure|failures">failure</dfn>,
|
415 | 421 | <dfn data-cite="shacl12-core#dfn-shacl-instance" data-lt="shacl instance">SHACL instance</dfn>,
|
@@ -1206,6 +1212,119 @@ <h3>Validation with SPARQL-based Constraint Components</h3>
|
1206 | 1212 | </section>
|
1207 | 1213 | </section>
|
1208 | 1214 |
|
| 1215 | + <section id="sparql-node-expressions"> |
| 1216 | + <h2>SPARQL-based Node Expressions</h2> |
| 1217 | + <p> |
| 1218 | + This section introduces <a>node expression functions</a> based on SPARQL. |
| 1219 | + </p> |
| 1220 | + |
| 1221 | + <section id="SelectExpression"> |
| 1222 | + <h3>Select Expressions</h3> |
| 1223 | + <p> |
| 1224 | + A <a>node expression</a> that has a <a>value</a> for <code>sh:select</code> is called a <dfn>select expression</dfn> with the <a>function name</a> |
| 1225 | + <code>sh:SelectExpression</code>. |
| 1226 | + </p> |
| 1227 | + <p class="syntax"> |
| 1228 | + <span data-syntax-rule="SelectExpression-syntax">A node in an RDF graph is a <a>well-formed</a> <a>select expression</a> if it is a <a>blank node</a> |
| 1229 | + that is the <a>subject</a> of exactly one <a>triple</a> with <code>sh:select</code> as <a>predicate</a> and a <a>literal</a> as <a>object</a> |
| 1230 | + with <a>datatype</a> <code>xsd:string</code>.</span> |
| 1231 | + <span data-syntax-rule="SelectExpression-query-valid">Using the <a href="#sparql-prefixes">prefix handling rules</a>, the value of <code>sh:select</code> is a valid SPARQL 1.2 SELECT query.</span> |
| 1232 | + <span data-syntax-rule="SelectExpression-query-output-nodes">The SPARQL query derived from the value of <code>sh:select</code> <a data-cite="sparql12-query/#selectproject">projects</a> exactly one variable in the SELECT clause.</span> |
| 1233 | + </p> |
| 1234 | + <div class="def" id="LiteralExpression-evaluation"> |
| 1235 | + <div class="def-header">EVALUATION OF SELECT EXPRESSIONS</div> |
| 1236 | + <p> |
| 1237 | + 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) |
| 1238 | + variable that is projected from the SELECT clause. |
| 1239 | + 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>. |
| 1240 | + <br/> |
| 1241 | + <br/> |
| 1242 | + <code>eval(expr, activeGraph, scope) -> resultNodes</code> |
| 1243 | + </p> |
| 1244 | + </div> |
| 1245 | + <p><em>The remainder of this section is informative.</em></p> |
| 1246 | + <aside class="example" title="A dynamically computed property using a node expression based on a SPARQL query"> |
| 1247 | + <p> |
| 1248 | + Here is an example use of a <a>select expression</a>, computing the values of a property shape for the property |
| 1249 | + "full name" as the concatenation of the <code>ex:firstName</code>, a space, and the <code>ex:lastName</code>. |
| 1250 | + </p> |
| 1251 | + <div class="shapes-graph"> |
| 1252 | + <div class="turtle"> |
| 1253 | +ex:Person-fullName |
| 1254 | + a sh:PropertyShape ; |
| 1255 | + sh:name "full name" ; |
| 1256 | + sh:path ex:fullName ; |
| 1257 | + sh:values <b>[ |
| 1258 | + sh:prefixes <http://example.org/ns> ; |
| 1259 | + sh:select """ |
| 1260 | + SELECT ?fullName |
| 1261 | + WHERE { |
| 1262 | + $this ex:firstName ?firstName . |
| 1263 | + $this ex:lastName ?lastName . |
| 1264 | + BIND (CONCAT(?firstName, " ", ?lastName) AS ?fullName) . |
| 1265 | + } |
| 1266 | + """ |
| 1267 | + ]</b> ; |
| 1268 | + sh:datatype xsd:string . |
| 1269 | + |
| 1270 | +<http://example.org/ns> |
| 1271 | + a owl:Ontology ; |
| 1272 | + sh:declare [ |
| 1273 | + sh:prefix "ex" ; |
| 1274 | + sh:namespace "http://example.org/ns#"^^xsd:anyURI ; |
| 1275 | + ] . |
| 1276 | + </div> |
| 1277 | + </div> |
| 1278 | + <p> |
| 1279 | + This example also illustrates the use of <code>sh:prefixes</code> to insert PREFIX declarations into the beginning of the query before parsing. |
| 1280 | + Note that the query is executed with the current <a>focus node</a> <a>pre-bound</a> to the variable <code>this</code>. |
| 1281 | + </p> |
| 1282 | + </aside> |
| 1283 | + <aside class="example" title="Dynamically computed target nodes using a node expression based on a SPARQL query"> |
| 1284 | + <p> |
| 1285 | + Here is an example use of a <a>select expression</a>, computing the target nodes of a shape to consist of all instances of |
| 1286 | + <code>ex:Person</code> where the <code>ex:age</code> is less than <code>18</code>. |
| 1287 | + </p> |
| 1288 | + <div class="shapes-graph"> |
| 1289 | + <div class="turtle"> |
| 1290 | +ex:ChildShape |
| 1291 | + a sh:NodeShape ; |
| 1292 | + rdfs:label "Child shape" ; |
| 1293 | + rdfs:comment "This shape applies to all persons under 18 years of age." ; |
| 1294 | + sh:targetNode <b>[ |
| 1295 | + sh:select """ |
| 1296 | + PREFIX ex: <http://example.org/ns#> |
| 1297 | + SELECT ?person |
| 1298 | + WHERE { |
| 1299 | + ?person a/rdfs:subClassOf* ex:Person . |
| 1300 | + ?person ex:age ?age . |
| 1301 | + FILTER (?age < 18) . |
| 1302 | + } |
| 1303 | + """ |
| 1304 | + ]</b> . |
| 1305 | + </div> |
| 1306 | + </div> |
| 1307 | + <p> |
| 1308 | + From the following data graph, only <code>ex:Benjamin</code> is a target node. |
| 1309 | + </p> |
| 1310 | + <div class="data-graph"> |
| 1311 | + <div class="turtle"> |
| 1312 | +<span class="focus-node-selected">ex:Benjamin</span> |
| 1313 | + a ex:Person ; |
| 1314 | + ex:age 17 . |
| 1315 | + |
| 1316 | +ex:Klaus |
| 1317 | + a ex:Person ; |
| 1318 | + ex:age 48 . |
| 1319 | + |
| 1320 | +ex:Bernd |
| 1321 | + a ex:Person . |
| 1322 | + </div> |
| 1323 | + </div> |
| 1324 | + </aside> |
| 1325 | + </section> |
| 1326 | + </section> |
| 1327 | + |
1209 | 1328 | <div style="padding-top: 30px">
|
1210 | 1329 | <h1 id="appendix" style="font-size: 160%; font-weight: bold">Appendix</h1>
|
1211 | 1330 | </div>
|
@@ -1535,6 +1654,13 @@ <h2>Revision History</h2>
|
1535 | 1654 | <li><b>2024-02-14</b>: New work started by cloning the main SHACL spec and splitting it into SHACL Core and SHACL-SPARQL</li>
|
1536 | 1655 | </ul>
|
1537 | 1656 | </section>
|
| 1657 | + |
| 1658 | + <section class="appendix informative" id="changes-12"> |
| 1659 | + <h2>Changes between SHACL 1.0 SPARQL and SHACL 1.2 SPARQL Extensions</h2> |
| 1660 | + <ul> |
| 1661 | + <li>Added the <a>node expression function</a> <a href="#SelectExpression"><code>sh:SelectExpression</code></a>, see <a href="https://github.com/w3c/data-shapes/issues/288">Issue 288</a></li> |
| 1662 | + </ul> |
| 1663 | + </section> |
1538 | 1664 |
|
1539 | 1665 | </body>
|
1540 | 1666 |
|
|
0 commit comments