Skip to content

feat: #407 add support for sh:TripleTerm to sh:nodeKind and allow lists #410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 73 additions & 6 deletions shacl12-core/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3432,24 +3432,30 @@ <h4>sh:nodeKind</h4>
<tr>
<td><code>sh:nodeKind</code></td>
<td>
The node kind (IRI, blank node, literal or combinations of these) of all value nodes.
<span data-syntax-rule="nodeKind-in">The values of <code>sh:nodeKind</code> in a shape are one of the following six instances of the class <code>sh:NodeKind</code>:
<code>sh:BlankNode</code>, <code>sh:IRI</code>, <code>sh:Literal</code>
<code>sh:BlankNodeOrIRI</code>, <code>sh:BlankNodeOrLiteral</code> and <code>sh:IRIOrLiteral</code>.</span>
The node kind (IRI, blank node, literal, triple term or combinations of these) of all value nodes.
<span data-syntax-rule="nodeKind-maxCount">A shape has at most one value for <code>sh:nodeKind</code>.</span>
The value of sh:nodeKind in a shape is either an IRI or a blank node that is a well-formed SHACL list where all members are IRIs.
<span data-syntax-rule="nodeKind-in">The values or members of <code>sh:nodeKind</code> in a shape are one of the following seven instances of the class <code>sh:NodeKind</code>:
<code>sh:BlankNode</code>, <code>sh:IRI</code>, <code>sh:Literal</code>
<code>sh:BlankNodeOrIRI</code>, <code>sh:BlankNodeOrLiteral</code>, <code>sh:IRIOrLiteral</code> and <code>sh:TripleTerm</code>.</span>
</td>
</tr>
</table>
<div class="def def-text">
<div class="def-header">TEXTUAL DEFINITION</div>
<div class="def-text-body" data-validator="NodeKind">
Let <code>$nodeKind</code> be a <a>parameter value</a> for <code>sh:nodeKind</code>.
Let <code>$nodeKinds</code> be a set of <a>IRIs</a> so that
when <code>$nodeKind</code> is an <a>IRI</a> then the set only consists of exactly that IRI,
and when <code>$nodeKind</code> is a <a>blank node</a> <a>SHACL list</a> then the set consists of
exactly the members of the list.<br /><br />
For each <a>value node</a>
that does not match <code>$nodeKind</code>,
that matches none of the <code>$nodeKinds</code>,
there is a <a>validation result</a> with the <a>value node</a> as <code>sh:value</code>.
Any <a>IRI</a> matches only <code>sh:IRI</code>, <code>sh:BlankNodeOrIRI</code> and <code>sh:IRIOrLiteral</code>.
Any <a>blank node</a> matches only <code>sh:BlankNode</code>, <code>sh:BlankNodeOrIRI</code> and <code>sh:BlankNodeOrLiteral</code>.
Any <a>literal</a> matches only <code>sh:Literal</code>, <code>sh:BlankNodeOrLiteral</code> and <code>sh:IRIOrLiteral</code>.
Any <a>triple term</a> matches only <code>sh:TripleTerm</code>.
</div>
</div>
<p><em>The remainder of this section is informative.</em></p>
Expand Down Expand Up @@ -3480,7 +3486,7 @@ <h4>sh:nodeKind</h4>
<div class="data-graph">
<div class="turtle">
ex:Bob ex:knows ex:Alice .
ex:Alice ex:knows <span class="focus-node-error">"Bob"</span> .
ex:Alice ex:knows <span class="focus-node-error">"Bob"</span> .
</div>
<div class="jsonld">
<pre class="jsonld">{
Expand All @@ -3496,6 +3502,67 @@ <h4>sh:nodeKind</h4>
}
}
]
}</pre>
</div>
</div>
</aside>
<p>
The following example illustrates the list-based syntax, meaning that all values of <code>ex:knows</code>
need to be IRIs or blank nodes, at any subject.
</p>
<aside class="example">
<div class="shapes-graph">
<div class="turtle">
ex:NodeKindExampleShape
a sh:NodeShape ;
<span class="target-can-be-skipped">sh:targetObjectsOf ex:knows ;</span>
sh:nodeKind ( sh:BlankNode sh:IRI ) .
</div>
<div class="jsonld">
<pre class="jsonld">{
"@id": "ex:NodeKindExampleShape",
"@type": "sh:NodeShape",
"sh:nodeKind": {
"@list": [
{
"@id": "sh:BlankNode"
},
{
"@id": "sh:IRI"
}
]
},
"sh:targetObjectsOf": {
"@id": "ex:knows"
}
}</pre>
</div>
</div>
<div class="data-graph">
<div class="turtle">
ex:Bob ex:knows ex:Alice .
ex:Bob ex:knows _:john .
ex:Alice ex:knows <span class="focus-node-error">"Bob"</span> .
</div>
<div class="jsonld">
<pre class="jsonld">{
"@graph": [
{
"@id": "ex:Alice",
"ex:knows": "Bob"
},
{
"@id": "ex:Bob",
"ex:knows": [
{
"@id": "ex:Alice"
},
{
"@id": "_:b1"
}
]
}
]
}</pre>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions shacl12-test-suite/tests/core/node/manifest.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
mf:include <minLength-001.ttl> ;
mf:include <node-001.ttl> ;
mf:include <nodeKind-001.ttl> ;
mf:include <nodeKind-002.ttl> ;
mf:include <not-001.ttl> ;
mf:include <not-002.ttl> ;
mf:include <or-001.ttl> ;
Expand Down
44 changes: 44 additions & 0 deletions shacl12-test-suite/tests/core/node/nodeKind-002.ttl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://datashapes.org/sh/tests/core/node/nodeKind-002.test#> .
@prefix mf: <http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix sht: <http://www.w3.org/ns/shacl-test#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:IRITestShape
rdf:type sh:NodeShape ;
sh:nodeKind ( sh:BlankNode sh:IRI ) ;
sh:targetNode ex:John ;
sh:targetNode _:bob ;
sh:targetNode "true"^^xsd:boolean ;
.
<>
rdf:type mf:Manifest ;
mf:entries (
<nodeKind-002>
) ;
.
<nodeKind-002>
rdf:type sht:Validate ;
rdfs:label "Test of sh:nodeKind at node shape 002" ;
mf:action [
sht:dataGraph <> ;
sht:shapesGraph <> ;
] ;
mf:result [
rdf:type sh:ValidationReport ;
sh:conforms "false"^^xsd:boolean ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode "true"^^xsd:boolean ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:NodeKindConstraintComponent ;
sh:sourceShape ex:IRITestShape ;
sh:value "true"^^xsd:boolean ;
] ;
] ;
mf:status sht:approved ;
.
5 changes: 5 additions & 0 deletions shacl12-vocabularies/shacl.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@ sh:Literal
rdfs:comment "The node kind of all literals."@en ;
rdfs:isDefinedBy sh: .

sh:TripleTerm
a sh:NodeKind ;
rdfs:label "Triple term"@en ;
rdfs:comment "The node kind of all triple terms."@en ;
rdfs:isDefinedBy sh: .

# Results vocabulary ----------------------------------------------------------

Expand Down