-
Notifications
You must be signed in to change notification settings - Fork 30
#300: Added support for RDF 1.2 triple terms #368
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
Changes from 3 commits
f8242fc
7551c02
de746c3
345eb4c
48bef5e
c598b86
3ced0c9
2c0a282
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -495,6 +495,8 @@ <h3>Terminology</h3> | |
<dfn data-cite="rdf12-concepts#dfn-literal" data-lt="literal|literals">literal</dfn>, | ||
<dfn data-cite="rdf12-concepts#dfn-datatype" data-lt="datatype">datatype</dfn>, | ||
<dfn data-cite="rdf12-concepts#dfn-blank-node" data-lt="blank node|blank nodes">blank node</dfn>, | ||
<dfn data-cite="rdf12-concepts#dfn-triple-term" data-lt="triple term|triple terms">triple term</dfn>, | ||
<dfn data-cite="rdf12-concepts#dfn-reifier" data-lt="reifier">reifier</dfn>, | ||
<dfn data-cite="rdf12-concepts#dfn-node" data-lt="node|nodes">node</dfn> of an RDF graph, | ||
<dfn data-cite="rdf12-concepts#dfn-rdf-term" data-lt="term|terms">RDF term</dfn>, | ||
<dfn data-cite="rdf12-concepts#dfn-subject" data-lt="subject|subjects">subject</dfn>, | ||
|
@@ -2062,7 +2064,9 @@ <h3>Property Shapes</h3> | |
that is the <a>subject</a> of a <a>triple</a> that has <code>sh:path</code> as its <a>predicate</a>.</span> | ||
<span data-syntax-rule="path-maxCount">A shape has at most one <a>value</a> for <code>sh:path</code>.</span> | ||
<span data-syntax-rule="path-node">The <a>value</a> of <code>sh:path</code> in a property shape is a <a>well-formed</a> | ||
<a>SHACL property path</a>.</span> | ||
<a>SHACL property path</a>. If a property shape contains a <code>sh:ReifiableByConstraintComponent</code>, | ||
<code>sh:path</code> values are constrained to IRIs.</span> | ||
|
||
<br/><br/> | ||
It is recommended, but not required, for a <a>property shape</a> to be declared as a <a>SHACL instance</a> of <code>sh:PropertyShape</code>. | ||
<span data-syntax-rule="PropertyShape-path-minCount"><a>SHACL instances</a> of <code>sh:PropertyShape</code> have one <a>value</a> for the property <code>sh:path</code>.</span> | ||
|
@@ -5683,6 +5687,98 @@ <h4>sh:qualifiedValueShape, sh:qualifiedMinCount, sh:qualifiedMaxCount</h4> | |
</div> | ||
</aside> | ||
</section> | ||
|
||
<section id="ReifiableByShapeConstraintComponent"> | ||
<h4>sh:reifiableBy, sh:reificationRequired</h4> | ||
<p> | ||
<code>sh:reifiableBy</code> can be used to link a <a>property shape</a> with one or more <a>node shapes</a>. | ||
Any reified statement must conform to these node shapes. | ||
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think SHACL needs to define validation for the basic forms then work up from there. This PR seems to be for an annotation usage pattern but that isn't the only way to use RDF 1.2. Starting with:
and
I think the intent is to apply a shape to the structure and also the triples insided Only Turtle/TriG have this annotation syntax. Data does not have to use Sometimes, there may not be an asserted triple:
which is 3 triples:
Note the shared blank node. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it's for the use case where an asserted triple can be used to traverse into the triple term. The text definition says that the reifier will become the focus node for that validation. Based on the discussion in #300, I thought we don't need to cover the use case without asserted triples. Node Expressions, or SPARQL-based targets can be used for that use case. |
||
</p> | ||
|
||
<div class="parameters">Parameters:</div> | ||
<table class="term-table"> | ||
<tr> | ||
<th>Property</th> | ||
<th>Summary and Syntax Rules</th> | ||
</tr> | ||
<tr> | ||
<td><code>sh:reifiableBy</code></td> | ||
<td> | ||
The <a>node shape</a> that the reified statement must conform to. | ||
<span data-syntax-rule="reifiableBy-node">The values of <code>sh:reifiableBy</code> must be <a>well-formed</a> <a>node shapes</a>.</span> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td><code>sh:reificationRequired</code></td> | ||
<td> | ||
This is an <a>optional parameter</a> of <code>sh:ReifiableByConstraintComponent</code>. | ||
If set to <code>true</code> there must be at least one reification value for the focus node/path combination in the <a>data graph</a>. | ||
bergos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<span data-syntax-rule="reificationRequired-datatype">The values of <code>sh:reificationRequired</code> in a shape are literals with datatype <code>xsd:boolean</code>.</span> | ||
</td> | ||
</tr> | ||
</table> | ||
|
||
<div class="def def-text"> | ||
<div class="def-header">TEXTUAL DEFINITION</div> | ||
<div class="def-text-body" data-validator="ReifiableBy"> | ||
Let <code>t</code> be the <a>triple terms</a> (<a>focus node</a>, <code>$path</code>, <a>value node</a>). | ||
bergos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
For each reified statement for the <a>triple terms</a> <code>t</code>, a failure MUST be produced if the validation of the reified statement with the <a>reifier</a> as <a>focus node</a> against the <a>node shape</a> <code>$reifiableBy</code> produces a <a>failure</a>. | ||
bergos marked this conversation as resolved.
Show resolved
Hide resolved
bergos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
</div> | ||
|
||
<div class="def def-text"> | ||
<div class="def-header">TEXTUAL DEFINITION of sh:reificationRequired</div> | ||
<div class="def-text-body" data-validator="ReificationRequired"> | ||
If <code>$reificationRequired</code> is set to <code>true</code>, a failure MUST be produced when there is no reified statement for the <a>triple term</a> <code>t</code> in the <a>data graph</a>. | ||
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There can be zero or more groups of triples
In this example, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
How? SPARQL-based constraints can do many things but what would node expressions look like? General observation: Pushing things onto node expressions may work technically but they aren't necessarily a friendly way to express things. If the WG decides to publish core as a REC ASAP, then core is then fixed and unchangeable. The WG needs to be certain that pushing out things out to phase2 actually ends up with the best outcome. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can handle that change in a separate PR. That's why I've moved the discussion back to the issue. |
||
</div> | ||
</div> | ||
|
||
<aside class="example"> | ||
<div class="shapes-graph"> | ||
<div class="turtle"> | ||
ex:ProvenanceShape | ||
a sh:NodeShape ; | ||
sh:property [ | ||
sh:path ex:date ; | ||
sh:datatype xsd:date ; | ||
sh:maxCount 1 ; | ||
] ; | ||
sh:property [ | ||
sh:path ex:author ; | ||
sh:nodeKind sh:IRI ; | ||
sh:maxCount 1 ; | ||
] . | ||
|
||
ex:PersonShape | ||
a sh:NodeShape ; | ||
sh:targetClass ex:Person ; | ||
sh:property ex:PersonShape-age . | ||
|
||
ex:PersonShape-age | ||
a sh:PropertyShape ; | ||
sh:path ex:age ; | ||
sh:datatype xsd:integer ; | ||
sh:maxCount 1 ; | ||
sh:reifiableBy ex:ProvenanceShape ; | ||
sh:reificationRequired true . | ||
</div> | ||
<div class="jsonld"> | ||
<pre class="jsonld"></pre> | ||
</div> | ||
</div> | ||
<div class="data-graph"> | ||
<div class="turtle"> | ||
ex:Bob ex:age 23 {| | ||
ex:date "2019-12-05"^^xsd:date . | ||
ex:author ex:Claire | ||
|}. | ||
</div> | ||
<div class="jsonld"> | ||
<pre class="jsonld"></pre> | ||
</div> | ||
</div> | ||
</aside> | ||
</section> | ||
</section> | ||
|
||
<section id="core-components-others"> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
@prefix dash: <http://datashapes.org/dash#> . | ||
@prefix ex: <http://datashapes.org/sh/tests/core/node/reifiableBy-001.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:InvalidResource1 | ||
ex:propertyA "invalid" {| | ||
ex:propertyB false ; | ||
|} ; | ||
. | ||
ex:ReifyShape | ||
rdf:type sh:NodeShape ; | ||
sh:property ex:ReifyShape-propertyB ; | ||
. | ||
ex:ReifyShape-propertyB | ||
sh:path ex:propertyB ; | ||
sh:in ( true ) ; | ||
. | ||
ex:TestShape | ||
rdf:type sh:NodeShape ; | ||
rdfs:label "Test shape" ; | ||
sh:property ex:TestShape-propertyA ; | ||
sh:targetNode ex:InvalidResource1 ; | ||
sh:targetNode ex:ValidResource1 ; | ||
. | ||
ex:TestShape-propertyA | ||
sh:path ex:propertyA ; | ||
sh:reifiableBy ex:ReifyShape ; | ||
. | ||
ex:ValidResource1 | ||
ex:propertyA "valid" {| | ||
ex:properrtyB true ; | ||
bergos marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|} ; | ||
. | ||
<> | ||
rdf:type mf:Manifest ; | ||
mf:entries ( | ||
<reifiableBy-001> | ||
) ; | ||
. | ||
<reifiableBy-001> | ||
rdf:type sht:Validate ; | ||
rdfs:label "Test of sh:reifiableBy 001" ; | ||
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 ex:InvalidResource1 ; | ||
sh:resultSeverity sh:Violation ; | ||
sh:sourceConstraintComponent sh:ReifiableByConstraintComponent ; | ||
sh:sourceShape ex:TestShape-propertyA ; | ||
sh:value "invalid" ; | ||
] ; | ||
] ; | ||
mf:status sht:approved ; | ||
. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
@prefix dash: <http://datashapes.org/dash#> . | ||
@prefix ex: <http://datashapes.org/sh/tests/core/node/reifiableBy-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:InvalidResource1 | ||
ex:propertyA "invalid" ; | ||
. | ||
ex:ReifyShape | ||
rdf:type sh:NodeShape ; | ||
sh:property ex:ReifyShape-propertyB ; | ||
. | ||
ex:ReifyShape-propertyB | ||
sh:path ex:propertyB ; | ||
. | ||
ex:TestShape | ||
rdf:type sh:NodeShape ; | ||
rdfs:label "Test shape" ; | ||
sh:property ex:TestShape-propertyA ; | ||
sh:targetNode ex:InvalidResource1 ; | ||
sh:targetNode ex:ValidResource1 ; | ||
. | ||
ex:TestShape-propertyA | ||
sh:path ex:propertyA ; | ||
sh:reifiableBy ex:ReifyShape ; | ||
sh:reificationRequired true ; | ||
. | ||
ex:ValidResource1 | ||
ex:propertyA "valid" {| | ||
ex:properrtyB true ; | ||
|} ; | ||
. | ||
<> | ||
rdf:type mf:Manifest ; | ||
mf:entries ( | ||
<reifiableBy-002> | ||
) ; | ||
. | ||
<reifiableBy-002> | ||
rdf:type sht:Validate ; | ||
rdfs:label "Test of sh:reifiableBy 002 with sh:reificationRequired" ; | ||
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 ex:InvalidResource1 ; | ||
sh:resultSeverity sh:Violation ; | ||
sh:sourceConstraintComponent sh:ReifiableByConstraintComponent ; | ||
sh:sourceShape ex:TestShape-propertyA ; | ||
sh:value "invalid" ; | ||
] ; | ||
] ; | ||
mf:status sht:approved ; | ||
. |
Uh oh!
There was an error while loading. Please reload this page.