Skip to content

Commit 8bbb09a

Browse files
committed
Merge branch 'gh-pages' and add the two examples of sh:order
2 parents 49a847a + 7a87d28 commit 8bbb09a

File tree

10 files changed

+2759
-142
lines changed

10 files changed

+2759
-142
lines changed

shacl12-core/index.html

Lines changed: 2362 additions & 141 deletions
Large diffs are not rendered by default.

shacl12-sparql/index.html

Lines changed: 127 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
w3cid: 58399
8585
}
8686
],
87-
testSuiteURI: "http://w3c.github.io/data-shapes/data-shapes-test-suite/",
87+
testSuiteURI: "https://w3c.github.io/data-shapes/data-shapes-test-suite/",
8888

8989
previousPublishDate: "2017-07-20",
9090
previousMaturity: "REC",
@@ -383,6 +383,7 @@ <h3>Terminology</h3>
383383
<dfn data-cite="rdf12-concepts#dfn-literal" data-lt="literal|literals">literal</dfn>,
384384
<dfn data-cite="rdf12-concepts#dfn-blank-node" data-lt="blank node|blank nodes">blank node</dfn>,
385385
<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>,
386387
<dfn data-cite="rdf12-concepts#dfn-rdf-term" data-lt="term|terms">RDF term</dfn>, and
387388
<dfn data-cite="rdf12-concepts#dfn-subject" data-lt="subject|subjects">subject</dfn>,
388389
<dfn data-cite="rdf12-concepts#dfn-predicate" data-lt="predicate|predicates">predicate</dfn>, and
@@ -410,6 +411,11 @@ <h3>Terminology</h3>
410411
<dfn data-cite="shacl12-core#dfn-shapes-graph" data-lt="shapes graph">shapes graph</dfn>,
411412
<dfn data-cite="shacl12-core#dfn-target" data-lt="target|targets">target</dfn>,
412413
<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>,
413419
<dfn data-cite="shacl12-core#dfn-conform" data-lt="conform|conforms">conform</dfn>,
414420
<dfn data-cite="shacl12-core#dfn-failure" data-lt="failure|failures">failure</dfn>,
415421
<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>
12061212
</section>
12071213
</section>
12081214

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 &lt;http://example.org/ns&gt; ;
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+
&lt;http://example.org/ns&gt;
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: &lt;http://example.org/ns#&gt;
1297+
SELECT ?person
1298+
WHERE {
1299+
?person a/rdfs:subClassOf* ex:Person .
1300+
?person ex:age ?age .
1301+
FILTER (?age &lt; 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+
12091328
<div style="padding-top: 30px">
12101329
<h1 id="appendix" style="font-size: 160%; font-weight: bold">Appendix</h1>
12111330
</div>
@@ -1535,6 +1654,13 @@ <h2>Revision History</h2>
15351654
<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>
15361655
</ul>
15371656
</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>
15381664

15391665
</body>
15401666

shacl12-test-suite/tests/core/targets/manifest.ttl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
mf:include <multipleTargets-001.ttl> ;
99
mf:include <targetClass-001.ttl> ;
1010
mf:include <targetClassImplicit-001.ttl> ;
11+
mf:include <targetClassImplicit-002.ttl> ;
1112
mf:include <targetNode-001.ttl> ;
1213
mf:include <targetObjectsOf-001.ttl> ;
1314
mf:include <targetSubjectsOf-001.ttl> ;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
@prefix dash: <http://datashapes.org/dash#> .
2+
@prefix ex: <http://datashapes.org/sh/tests/core/targets/targetClassImplicit-002.test#> .
3+
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
4+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
5+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
6+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
7+
@prefix sh: <http://www.w3.org/ns/shacl#> .
8+
@prefix sht: <http://www.w3.org/ns/shacl-test#> .
9+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
10+
11+
ex:InvalidInstance
12+
rdf:type ex:SubClass ;
13+
rdfs:label "Invalid instance" ;
14+
.
15+
ex:SubClass
16+
rdf:type rdfs:Class ;
17+
rdfs:label "Sub class" ;
18+
rdfs:subClassOf ex:SuperClass ;
19+
.
20+
ex:SuperClass
21+
a sh:ShapeClass ;
22+
rdfs:label "Super class" ;
23+
sh:in (
24+
ex:ValidInstance
25+
) ;
26+
.
27+
ex:ValidInstance
28+
rdf:type ex:SubClass ;
29+
rdfs:label "Valid instance" ;
30+
.
31+
<>
32+
rdf:type mf:Manifest ;
33+
mf:entries (
34+
<targetClassImplicit-002>
35+
) ;
36+
.
37+
<targetClassImplicit-002>
38+
rdf:type sht:Validate ;
39+
rdfs:label "Verify that sh:ShapeClass is interpreted as implicit class target" ;
40+
mf:action [
41+
sht:dataGraph <> ;
42+
sht:shapesGraph <> ;
43+
] ;
44+
mf:result [
45+
rdf:type sh:ValidationReport ;
46+
sh:conforms "false"^^xsd:boolean ;
47+
sh:result [
48+
rdf:type sh:ValidationResult ;
49+
sh:focusNode ex:InvalidInstance ;
50+
sh:resultSeverity sh:Violation ;
51+
sh:sourceConstraintComponent sh:InConstraintComponent ;
52+
sh:sourceShape ex:SuperClass ;
53+
sh:value ex:InvalidInstance ;
54+
] ;
55+
] ;
56+
mf:status sht:approved ;
57+
.

shacl12-test-suite/tests/sparql/manifest.ttl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
mf:include <node/manifest.ttl> ;
99
mf:include <property/manifest.ttl> ;
1010
mf:include <pre-binding/manifest.ttl> ;
11+
mf:include <targets/manifest.ttl> ;
1112
.

shacl12-test-suite/tests/sparql/property/manifest.ttl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@
55
<>
66
a mf:Manifest ;
77
rdfs:label "Tests converted from http://datashapes.org/sh/tests/tests/sparql/property" ;
8+
mf:include <property-select-001.ttl> ;
89
mf:include <sparql-001.ttl> ;
910
.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
@prefix dash: <http://datashapes.org/dash#> .
2+
@prefix ex: <http://example.org/ns#> .
3+
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
4+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
5+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
6+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
7+
@prefix sh: <http://www.w3.org/ns/shacl#> .
8+
@prefix sht: <http://www.w3.org/ns/shacl-test#> .
9+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
10+
11+
ex:Person-fullName
12+
a sh:PropertyShape ;
13+
sh:targetClass ex:Person ;
14+
sh:name "full name" ;
15+
sh:path ex:fullName ;
16+
sh:values [
17+
sh:prefixes <http://example.org/ns> ;
18+
sh:select """
19+
SELECT ?fullName
20+
WHERE {
21+
$this ex:firstName ?firstName .
22+
$this ex:lastName ?lastName .
23+
BIND (CONCAT(?firstName, " ", ?lastName) AS ?fullName) .
24+
}
25+
"""
26+
] ;
27+
sh:datatype xsd:string ;
28+
sh:hasValue "John Muir" .
29+
30+
<http://example.org/ns>
31+
a owl:Ontology ;
32+
sh:declare [
33+
sh:prefix "ex" ;
34+
sh:namespace "http://example.org/ns#"^^xsd:anyURI ;
35+
] .
36+
37+
ex:JohnMuir
38+
a ex:Person ;
39+
ex:firstName "John" ;
40+
ex:lastName "Muir" .
41+
42+
ex:JohnWayne
43+
a ex:Person ;
44+
ex:firstName "John" ;
45+
ex:lastName "Wayne" .
46+
47+
<>
48+
rdf:type mf:Manifest ;
49+
mf:entries (
50+
<property-select-001>
51+
) ;
52+
.
53+
<property-select-001>
54+
rdf:type sht:Validate ;
55+
rdfs:label "Test of a sh:property with a sh:select expression 001" ;
56+
mf:action [
57+
sht:dataGraph <> ;
58+
sht:shapesGraph <> ;
59+
] ;
60+
mf:result [
61+
rdf:type sh:ValidationReport ;
62+
sh:conforms "false"^^xsd:boolean ;
63+
sh:result [
64+
rdf:type sh:ValidationResult ;
65+
sh:focusNode ex:JohnWayne ;
66+
sh:resultPath ex:fullName ;
67+
sh:resultSeverity sh:Violation ;
68+
sh:sourceConstraintComponent sh:HasValueConstraintComponent ;
69+
sh:sourceShape ex:Person-fullName ;
70+
] ;
71+
] ;
72+
mf:status sht:approved ;
73+
.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
2+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
3+
@prefix sht: <http://www.w3.org/ns/shacl-test#> .
4+
5+
<>
6+
a mf:Manifest ;
7+
rdfs:label "Tests for SPARQL-based targets" ;
8+
mf:include <targetNode-select-001.ttl> ;
9+
.

0 commit comments

Comments
 (0)