Skip to content

Commit a62a421

Browse files
HolgerKnublauchrobert-david
authored andcommitted
GH-587: shnex:nodesWhere node expression (#611)
* #587: Added shnex:where * Formatting (including unrelated examples) * Renamed from shnex:where to shnex:nodesWhere * Applied PR feedback * Renamed nodesWhere to nodesMatching * Update index.html Changed sh:targetMatching to sh:targetWhere. --------- Co-authored-by: Robert David <[email protected]>
1 parent b46e56f commit a62a421

File tree

3 files changed

+360
-147
lines changed

3 files changed

+360
-147
lines changed

shacl12-node-expr/index.html

Lines changed: 165 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,8 +1067,8 @@ <h3>If Expressions</h3>
10671067
<div class="shapes-graph">
10681068
<div class="turtle">
10691069
ex:City
1070-
a sh:ShapeClass ;
1071-
sh:property ex:City-fillColor .
1070+
a sh:ShapeClass ;
1071+
sh:property ex:City-fillColor .
10721072

10731073
ex:City-fillColor
10741074
a sh:PropertyShape ;
@@ -1145,24 +1145,24 @@ <h3>Distinct Expressions</h3>
11451145
<div class="shapes-graph">
11461146
<div class="turtle">
11471147
ex:ClassShape
1148-
a sh:NodeShape ;
1149-
sh:targetClass rdfs:Class ;
1150-
sh:property ex:ClassShape-superClassesIncludingRoot .
1148+
a sh:NodeShape ;
1149+
sh:targetClass rdfs:Class ;
1150+
sh:property ex:ClassShape-superClassesIncludingRoot .
11511151

11521152
ex:ClassShape-superClassesIncludingRoot
1153-
a sh:PropertyShape ;
1154-
sh:path ex:superClassesIncludingRoot ;
1155-
sh:description "The superclasses of this, always including rdfs:Resource." ;
1156-
sh:values <b>[
1157-
shnex:distinct [
1158-
shnex:union (
1159-
[
1160-
shnex:pathValues [ sh:zeroOrMorePath rdfs:subClassOf ] ;
1161-
]
1162-
( rdfs:Resource )
1163-
)
1164-
]</b> ;
1165-
] .
1153+
a sh:PropertyShape ;
1154+
sh:path ex:superClassesIncludingRoot ;
1155+
sh:description "The superclasses of this, always including rdfs:Resource." ;
1156+
sh:values <b>[
1157+
shnex:distinct [
1158+
shnex:union (
1159+
[
1160+
shnex:pathValues [ sh:zeroOrMorePath rdfs:subClassOf ] ;
1161+
]
1162+
( rdfs:Resource )
1163+
)
1164+
]</b> ;
1165+
] .
11661166
</div>
11671167
</div>
11681168
</aside>
@@ -1215,13 +1215,13 @@ <h3>Intersection Expressions</h3>
12151215
<div class="shapes-graph">
12161216
<div class="turtle">
12171217
ex:DualCitizenShape
1218-
a sh:NodeShape ;
1219-
sh:targetNode <b>[
1220-
shnex:intersection (
1221-
[ shnex:instancesOf ex:Australian ]
1222-
[ shnex:instancesOf ex:German ]
1223-
)
1224-
]</b> .
1218+
a sh:NodeShape ;
1219+
sh:targetNode <b>[
1220+
shnex:intersection (
1221+
[ shnex:instancesOf ex:Australian ]
1222+
[ shnex:instancesOf ex:German ]
1223+
)
1224+
]</b> .
12251225
</div>
12261226
</div>
12271227
</aside>
@@ -1382,24 +1382,24 @@ <h3>Filter Shape Expressions</h3>
13821382
<div class="shapes-graph">
13831383
<div class="turtle">
13841384
ex:Person
1385-
a sh:ShapeClass ;
1386-
sh:property ex:Person-maleChildren .
1385+
a sh:ShapeClass ;
1386+
sh:property ex:Person-maleChildren .
13871387

13881388
ex:Person-maleChildren
1389-
a sh:PropertyShape ;
1390-
sh:path ex:maleChildren ;
1391-
sh:class ex:Person ;
1392-
sh:values <b>[
1393-
shnex:nodes</b> [
1394-
shnex:pathValues ex:child ;
1395-
] ;
1396-
<b>shnex:filterShape [
1397-
sh:property [
1398-
sh:path ex:gender ;
1399-
sh:hasValue "male" ;
1400-
]
1401-
] ;
1402-
]</b> .
1389+
a sh:PropertyShape ;
1390+
sh:path ex:maleChildren ;
1391+
sh:class ex:Person ;
1392+
sh:values <b>[
1393+
shnex:nodes [
1394+
shnex:pathValues ex:child ;
1395+
] ;
1396+
shnex:filterShape [
1397+
sh:property [
1398+
sh:path ex:gender ;
1399+
sh:hasValue "male" ;
1400+
]
1401+
] ;
1402+
]</b> .
14031403
</div>
14041404
</div>
14051405
</aside>
@@ -1467,23 +1467,23 @@ <h3>Limit Expressions</h3>
14671467
<div class="shapes-graph">
14681468
<div class="turtle">
14691469
ex:PersonShape
1470-
a sh:NodeShape ;
1471-
sh:targetClass ex:Person ;
1472-
sh:property ex:PersonShape-oldestTwoChildren .
1470+
a sh:NodeShape ;
1471+
sh:targetClass ex:Person ;
1472+
sh:property ex:PersonShape-oldestTwoChildren .
14731473

14741474
ex:PersonShape-oldestTwoChildren
1475-
a sh:PropertyShape ;
1476-
sh:path ex:oldestTwoChildren ;
1477-
sh:class ex:Person ;
1478-
sh:values <b>[
1479-
shnex:nodes</b> [
1480-
shnex:nodes [
1481-
shnex:pathValues ex:child ;
1482-
] ;
1483-
shnex:orderBy ex:dateOfBirth ;
1484-
] ;
1485-
<b>shnex:limit 2 ;
1486-
]</b> .
1475+
a sh:PropertyShape ;
1476+
sh:path ex:oldestTwoChildren ;
1477+
sh:class ex:Person ;
1478+
sh:values <b>[
1479+
shnex:nodes [
1480+
shnex:nodes [
1481+
shnex:pathValues ex:child ;
1482+
] ;
1483+
shnex:orderBy ex:dateOfBirth ;
1484+
] ;
1485+
shnex:limit 2 ;
1486+
]</b> .
14871487
</div>
14881488
</div>
14891489
</aside>
@@ -1551,23 +1551,23 @@ <h3>Offset Expressions</h3>
15511551
<div class="shapes-graph">
15521552
<div class="turtle">
15531553
ex:PersonShape
1554-
a sh:NodeShape ;
1555-
sh:targetClass ex:Person ;
1556-
sh:property ex:PersonShape-remainingChildren .
1554+
a sh:NodeShape ;
1555+
sh:targetClass ex:Person ;
1556+
sh:property ex:PersonShape-remainingChildren .
15571557

15581558
ex:PersonShape-remainingChildren
1559-
a sh:PropertyShape ;
1560-
sh:path ex:remainingChildren ;
1561-
sh:class ex:Person ;
1562-
sh:values <b>[
1563-
shnex:nodes</b> [
1564-
shnex:nodes [
1565-
shnex:pathValues ex:child ;
1566-
] ;
1567-
shnex:orderBy ex:dateOfBirth ;
1568-
] ;
1569-
<b>shnex:offset 1 ;
1570-
]</b> .
1559+
a sh:PropertyShape ;
1560+
sh:path ex:remainingChildren ;
1561+
sh:class ex:Person ;
1562+
sh:values <b>[
1563+
shnex:nodes [
1564+
shnex:nodes [
1565+
shnex:pathValues ex:child ;
1566+
] ;
1567+
shnex:orderBy ex:dateOfBirth ;
1568+
] ;
1569+
shnex:offset 1 ;
1570+
]</b> .
15711571
</div>
15721572
</div>
15731573
</aside>
@@ -1633,21 +1633,21 @@ <h3>Count Expressions</h3>
16331633
<div class="shapes-graph">
16341634
<div class="turtle">
16351635
skos:ConceptScheme
1636-
a rdfs:Class, sh:NodeShape ;
1637-
sh:property skos:ConceptScheme-topConceptCount .
1636+
a rdfs:Class, sh:NodeShape ;
1637+
sh:property skos:ConceptScheme-topConceptCount .
16381638

16391639
skos:ConceptScheme-topConceptCount
1640-
a sh:PropertyShape ;
1641-
sh:path ex:topConceptCount ;
1642-
sh:datatype xsd:integer ;
1643-
sh:description "The number of top concepts in this scheme." ;
1644-
sh:maxCount 1 ;
1645-
sh:name "top concept count" ;
1646-
sh:values [
1647-
shnex:count [
1648-
shnex:pathValues skos:hasTopConcept ;
1649-
] ;
1650-
] .
1640+
a sh:PropertyShape ;
1641+
sh:path ex:topConceptCount ;
1642+
sh:datatype xsd:integer ;
1643+
sh:description "The number of top concepts in this scheme." ;
1644+
sh:maxCount 1 ;
1645+
sh:name "top concept count" ;
1646+
sh:values <b>[
1647+
shnex:count [
1648+
shnex:pathValues skos:hasTopConcept ;
1649+
] ;
1650+
]</b> .
16511651
</div>
16521652
</div>
16531653
</aside>
@@ -1703,21 +1703,21 @@ <h3>Min Expressions</h3>
17031703
<div class="shapes-graph">
17041704
<div class="turtle">
17051705
ex:CompanyShape
1706-
a sh:NodeShape ;
1707-
sh:targetClass ex:Company ;
1708-
sh:property ex:CompanyShape-minStartDate .
1706+
a sh:NodeShape ;
1707+
sh:targetClass ex:Company ;
1708+
sh:property ex:CompanyShape-minStartDate .
17091709

17101710
ex:CompanyShape-minStartDate
1711-
a sh:PropertyShape ;
1712-
sh:path ex:minStartDate ;
1713-
sh:datatype xsd:date ;
1714-
sh:maxCount 1 ;
1715-
sh:name "min start date" ;
1716-
sh:values [
1717-
shnex:min [
1718-
shnex:pathValues ( ex:employee ex:startDate ) ;
1719-
] ;
1720-
] .
1711+
a sh:PropertyShape ;
1712+
sh:path ex:minStartDate ;
1713+
sh:datatype xsd:date ;
1714+
sh:maxCount 1 ;
1715+
sh:name "min start date" ;
1716+
sh:values <b>[
1717+
shnex:min [
1718+
shnex:pathValues ( ex:employee ex:startDate ) ;
1719+
] ;
1720+
]</b> .
17211721
</div>
17221722
</div>
17231723
</aside>
@@ -1873,6 +1873,74 @@ <h3>InstancesOf Expressions</h3>
18731873
</p>
18741874
</section>
18751875

1876+
<section id="NodesMatchingExpression">
1877+
<h3>Nodes Matching Expressions</h3>
1878+
<p class="syntax">
1879+
<span data-syntax-rule="NodesMatchingExpression-syntax">
1880+
A <a>blank node</a> that is the <a>subject</a> of the following properties
1881+
is called a <dfn>nodes matching expression</dfn> with the <a>function name</a> <code>shnex:NodesMatchingExpression</code>:
1882+
<table class="term-table">
1883+
<thead>
1884+
<th>Property</th>
1885+
<th>Constraints</th>
1886+
<th>Description</th>
1887+
</thead>
1888+
<tbody>
1889+
<tr>
1890+
<td><b><code>shnex:nodesMatching</code></b></td>
1891+
<td>
1892+
<code>sh:nodeKind sh:BlankNodeOrIRI</code><br/>
1893+
<span>Must be a <a>well-formed</a> <a>shape</a>.</span>
1894+
</td>
1895+
<td>
1896+
The shape that the <a>output nodes</a> must conform to.
1897+
</td>
1898+
</tr>
1899+
</tbody>
1900+
</table>
1901+
</span>
1902+
</p>
1903+
<div class="def" id="NodesMatchingExpression-evaluation">
1904+
<div class="def-header">EVALUATION OF NODES MATCHING EXPRESSIONS</div>
1905+
<p>
1906+
Let <code>shape</code> be the <a>value</a> of <code>shnex:nodesMatching</code> in a <a>nodes matching expression</a>.
1907+
The <a>output nodes</a> of the <a>nodes matching expression</a> are the <a>nodes</a> in the <a>focus graph</a>
1908+
that <a>conform</a> to <code>shape</code>.
1909+
</p>
1910+
</div>
1911+
<p><em>The remainder of this section is informative.</em></p>
1912+
<p>
1913+
Users of this node expression function should be aware that the list of output nodes may be very large
1914+
and that some implementations may not be able to efficiently process it.
1915+
</p>
1916+
<p>
1917+
The following example illustrates the use of <code>shnex:nodesMatching</code> to compute all instances of
1918+
<code>ex:Company</code> that have at least 100 employees.
1919+
</p>
1920+
<aside class="example" id="nodes-matching-example">
1921+
<div class="shapes-graph">
1922+
<div class="turtle">
1923+
ex:LargeCompanyShape
1924+
a sh:NodeShape ;
1925+
sh:targetNode <b>[
1926+
shnex:nodesMatching [
1927+
sh:class ex:Company ;
1928+
sh:property [
1929+
sh:path ex:employee ;
1930+
sh:minCount 100 ;
1931+
]
1932+
]
1933+
]</b> .
1934+
</div>
1935+
</div>
1936+
</aside>
1937+
<p>
1938+
The interpretation of <code>shnex:nodesMatching</code> is similar to <code>sh:targetWhere</code>.
1939+
The main differences are that <code>sh:targetWhere</code> is part of SHACL Core and that
1940+
<code>shnex:nodesMatching</code> can be used in arbitrary node expressions.
1941+
</p>
1942+
</section>
1943+
18761944
</section>
18771945

18781946
</section>

0 commit comments

Comments
 (0)