Skip to content

Commit 4f5d5df

Browse files
committed
chore: add examples to list constraints
1 parent 57a3b38 commit 4f5d5df

File tree

1 file changed

+218
-50
lines changed

1 file changed

+218
-50
lines changed

shacl12-core/index.html

Lines changed: 218 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4535,7 +4535,7 @@ <h4>sh:uniqueLang</h4>
45354535
<h3>List Constraint Components</h3>
45364536
<p>
45374537
The constraint components in this section apply to <a>value nodes</a> that are <a href="#syntax-rule-SHACL-list">SHACL lists</a>.
4538-
They specify conditions on the structure, length, and members of RDF lists.
4538+
They specify conditions on the structure, length, and members of SHACL lists.
45394539
</p>
45404540

45414541
<section id="MemberShapeConstraintComponent">
@@ -4566,7 +4566,7 @@ <h4>sh:memberShape</h4>
45664566
<div class="def-text-body" data-validator="MemberShape">
45674567
Let <code>$memberShape</code> be a <a>parameter value</a> for <code>sh:memberShape</code>.
45684568
Each <a>value node</a> <code>v</code> must be a <a href="#syntax-rule-SHACL-list">SHACL list</a> - if <code>v</code> is not a SHACL list there is a <a>validation result</a>.
4569-
If any member of <code>m</code> of the list <code>v</code> does not <a>conform</a> to <code>$memberShape</code>, there is a <a>validation result</a>. There must be at most one <a>validation result</a> for each list <code>v</code>.
4569+
If any member <code>m</code> of the list <code>v</code> does not <a>conform</a> to <code>$memberShape</code>, there is a <a>validation result</a>. There must be at most one <a>validation result</a> for each list <code>v</code>.
45704570
</div>
45714571
</div>
45724572
<p><em>The remainder of this section is informative.</em></p>
@@ -4577,6 +4577,9 @@ <h4>sh:memberShape</h4>
45774577
<p>
45784578
Examples of how to generate <code>sh:detail</code>s in validation results can be found in the test cases for <code>sh:memberShape</code> in the SHACL test suite: <a href="../shacl12-test-suite/tests/core/node/memberShape-001.ttl">memberShape-001.ttl</a>.
45794579
</p>
4580+
<p>
4581+
In the following example, all values of the property <code>ex:speakerOrder</code> must be SHACL lists with members that are IRIs.
4582+
</p>
45804583
<aside class="example">
45814584
<div class="shapes-graph">
45824585
<div class="turtle">
@@ -4588,18 +4591,13 @@ <h4>sh:memberShape</h4>
45884591
sh:memberShape [
45894592
sh:nodeKind sh:IRI ;
45904593
] ;
4591-
sh:maxCount 1 ;
45924594
] .
45934595
</div>
45944596
<div class="jsonld">
45954597
<pre class="jsonld">{
45964598
"@id": "ex:AgendaShape",
45974599
"@type": "sh:NodeShape",
45984600
"sh:property": {
4599-
"sh:maxCount": {
4600-
"@type": "xsd:integer",
4601-
"@value": "1"
4602-
},
46034601
"sh:memberShape": {
46044602
"sh:nodeKind": {
46054603
"@id": "sh:IRI"
@@ -4659,48 +4657,6 @@ <h4>sh:memberShape</h4>
46594657
}
46604658
}
46614659
]
4662-
}</pre>
4663-
</div>
4664-
</div>
4665-
<div class="validation-report">
4666-
<div class="turtle">
4667-
[] a sh:ValidationReport ;
4668-
sh:conforms false ;
4669-
sh:result [
4670-
a sh:ValidationResult ;
4671-
sh:focusNode ex:agenda2 ;
4672-
sh:resultMessage "List member does not have the required node kind sh:IRI." ;
4673-
sh:resultPath ex:speakerOrder ;
4674-
sh:resultSeverity sh:Violation ;
4675-
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
4676-
sh:sourceShape ex:AgendaShape ;
4677-
sh:value "Charlie" ;
4678-
] .
4679-
</div>
4680-
<div class="jsonld">
4681-
<pre class="jsonld">{
4682-
"@type": "sh:ValidationReport",
4683-
"sh:conforms": false,
4684-
"sh:result": {
4685-
"@type": "sh:ValidationResult",
4686-
"sh:focusNode": {
4687-
"@id": "ex:agenda2"
4688-
},
4689-
"sh:resultMessage": "List member does not have the required node kind sh:IRI.",
4690-
"sh:resultPath": {
4691-
"@id": "ex:speakerOrder"
4692-
},
4693-
"sh:resultSeverity": {
4694-
"@id": "sh:Violation"
4695-
},
4696-
"sh:sourceConstraintComponent": {
4697-
"@id": "sh:MemberShapeConstraintComponent"
4698-
},
4699-
"sh:sourceShape": {
4700-
"@id": "ex:AgendaShape"
4701-
},
4702-
"sh:value": "Charlie"
4703-
}
47044660
}</pre>
47054661
</div>
47064662
</div>
@@ -4740,6 +4696,74 @@ <h4>sh:minListLength</h4>
47404696
there is a <a>validation result</a>.
47414697
</div>
47424698
</div>
4699+
<p><em>The remainder of this section is informative.</em></p>
4700+
<p>
4701+
In the following example, all values of the property <code>ex:skills</code> must be SHACL lists with at least 1 member.
4702+
Additional test cases for <code>sh:minListLength</code> can be found in the SHACL test suite: <a href="../shacl12-test-suite/tests/core/node/minListLength-001.ttl">minListLength-001.ttl</a>.
4703+
</p>
4704+
<aside class="example">
4705+
<div class="shapes-graph">
4706+
<div class="turtle">
4707+
ex:PersonShape
4708+
a sh:NodeShape ;
4709+
<span class="target-can-be-skipped">sh:targetClass ex:Person ;</span>
4710+
sh:property [
4711+
sh:path ex:skills ;
4712+
sh:minListLength 1 ;
4713+
] .
4714+
</div>
4715+
<div class="jsonld">
4716+
<pre class="jsonld">{
4717+
"@id": "ex:PersonShape",
4718+
"@type": "sh:NodeShape",
4719+
"sh:property": {
4720+
"sh:minListLength": {
4721+
"@type": "xsd:integer",
4722+
"@value": "1"
4723+
},
4724+
"sh:path": {
4725+
"@id": "ex:skills"
4726+
}
4727+
},
4728+
"sh:targetClass": {
4729+
"@id": "ex:Person"
4730+
}
4731+
}</pre>
4732+
</div>
4733+
</div>
4734+
<div class="data-graph">
4735+
<div class="turtle">
4736+
ex:person1 a ex:Person ;
4737+
ex:skills ( "programming" "design" ) .
4738+
4739+
<span class="focus-node-error">ex:person2</span> a ex:Person ;
4740+
ex:skills () .
4741+
</div>
4742+
<div class="jsonld">
4743+
<pre class="jsonld">{
4744+
"@graph": [
4745+
{
4746+
"@id": "ex:person1",
4747+
"@type": "ex:Person",
4748+
"ex:skills": {
4749+
"@list": [
4750+
"programming",
4751+
"design"
4752+
]
4753+
}
4754+
},
4755+
{
4756+
"@id": "ex:person2",
4757+
"@type": "ex:Person",
4758+
"ex:skills": {
4759+
"@list": []
4760+
}
4761+
}
4762+
]
4763+
}</pre>
4764+
</div>
4765+
</div>
4766+
</aside>
47434767
</section>
47444768

47454769
<section id="MaxListLengthConstraintComponent">
@@ -4775,6 +4799,78 @@ <h4>sh:maxListLength</h4>
47754799
there is a <a>validation result</a>.
47764800
</div>
47774801
</div>
4802+
<p><em>The remainder of this section is informative.</em></p>
4803+
<p>
4804+
In the following example, all values of the property <code>ex:hobbies</code> must be SHACL lists with at most 2 members.
4805+
Additional test cases for <code>sh:maxListLength</code> can be found in the SHACL test suite: <a href="../shacl12-test-suite/tests/core/node/maxListLength-001.ttl">maxListLength-001.ttl</a>.
4806+
</p>
4807+
<aside class="example">
4808+
<div class="shapes-graph">
4809+
<div class="turtle">
4810+
ex:PersonShape
4811+
a sh:NodeShape ;
4812+
<span class="target-can-be-skipped">sh:targetClass ex:Person ;</span>
4813+
sh:property [
4814+
sh:path ex:hobbies ;
4815+
sh:maxListLength 2 ;
4816+
] .
4817+
</div>
4818+
<div class="jsonld">
4819+
<pre class="jsonld">{
4820+
"@id": "ex:PersonShape",
4821+
"@type": "sh:NodeShape",
4822+
"sh:property": {
4823+
"sh:maxListLength": {
4824+
"@type": "xsd:integer",
4825+
"@value": "2"
4826+
},
4827+
"sh:path": {
4828+
"@id": "ex:hobbies"
4829+
}
4830+
},
4831+
"sh:targetClass": {
4832+
"@id": "ex:Person"
4833+
}
4834+
}</pre>
4835+
</div>
4836+
</div>
4837+
<div class="data-graph">
4838+
<div class="turtle">
4839+
ex:person1 a ex:Person ;
4840+
ex:hobbies ( "reading" "writing" ) .
4841+
4842+
<span class="focus-node-error">ex:person2</span> a ex:Person ;
4843+
ex:hobbies ( "reading" "writing" "swimming" ) .
4844+
</div>
4845+
<div class="jsonld">
4846+
<pre class="jsonld">{
4847+
"@graph": [
4848+
{
4849+
"@id": "ex:person1",
4850+
"@type": "ex:Person",
4851+
"ex:hobbies": {
4852+
"@list": [
4853+
"reading",
4854+
"writing"
4855+
]
4856+
}
4857+
},
4858+
{
4859+
"@id": "ex:person2",
4860+
"@type": "ex:Person",
4861+
"ex:hobbies": {
4862+
"@list": [
4863+
"reading",
4864+
"writing",
4865+
"swimming"
4866+
]
4867+
}
4868+
}
4869+
]
4870+
}</pre>
4871+
</div>
4872+
</div>
4873+
</aside>
47784874
</section>
47794875

47804876
<section id="UniqueMembersConstraintComponent">
@@ -4811,11 +4907,83 @@ <h4>sh:uniqueMembers</h4>
48114907
</div>
48124908
<p><em>The remainder of this section is informative.</em></p>
48134909
<p>
4814-
Each duplicate member of a list <code>v</code> should be reported as a separate <code>sh:detail</code> in the <a>validation result</a> for <code>v</code>. If the list <code>v</code> is not a valid <a href="#syntax-rule-SHACL-list">SHACL list</a>, this should also be reported as a <code>sh:detail</code> in the <a>validation result</a> for <code>v</code>.
4910+
Each duplicate member <code>m</code> of a list <code>v</code> should be reported as a separate <code>sh:detail</code> in the <a>validation result</a> for <code>v</code>. If the list <code>v</code> is not a valid <a href="#syntax-rule-SHACL-list">SHACL list</a>, this should also be reported as a <code>sh:detail</code> in the <a>validation result</a> for <code>v</code>.
48154911
</p>
48164912
<p>
48174913
Examples of how to generate <code>sh:detail</code>s in validation results can be found in the test cases for <code>sh:uniqueMembers</code> in the SHACL test suite: <a href="../shacl12-test-suite/tests/core/node/uniqueMembers-001.ttl">uniqueMembers-001.ttl</a>.
48184914
</p>
4915+
<p>
4916+
In the following example, all values of the property <code>ex:preferences</code> must be SHACL lists with members that have unique values within each SHACL list.
4917+
</p>
4918+
<aside class="example">
4919+
<div class="shapes-graph">
4920+
<div class="turtle">
4921+
ex:PersonShape
4922+
a sh:NodeShape ;
4923+
<span class="target-can-be-skipped">sh:targetClass ex:Person ;</span>
4924+
sh:property [
4925+
sh:path ex:preferences ;
4926+
sh:uniqueMembers true ;
4927+
] .
4928+
</div>
4929+
<div class="jsonld">
4930+
<pre class="jsonld">{
4931+
"@id": "ex:PersonShape",
4932+
"@type": "sh:NodeShape",
4933+
"sh:property": {
4934+
"sh:uniqueMembers": {
4935+
"@type": "xsd:boolean",
4936+
"@value": "true"
4937+
},
4938+
"sh:path": {
4939+
"@id": "ex:preferences"
4940+
}
4941+
},
4942+
"sh:targetClass": {
4943+
"@id": "ex:Person"
4944+
}
4945+
}</pre>
4946+
</div>
4947+
</div>
4948+
<div class="data-graph">
4949+
<div class="turtle">
4950+
ex:person1 a ex:Person ;
4951+
ex:preferences ( "coffee" "tea" ) .
4952+
4953+
<span class="focus-node-error">ex:person2</span> a ex:Person ;
4954+
ex:preferences ( "coffee" "tea" "coffee" "tea" "tea" ) .
4955+
</div>
4956+
<div class="jsonld">
4957+
<pre class="jsonld">{
4958+
"@graph": [
4959+
{
4960+
"@id": "ex:person1",
4961+
"@type": "ex:Person",
4962+
"ex:preferences": {
4963+
"@list": [
4964+
"coffee",
4965+
"tea"
4966+
]
4967+
}
4968+
},
4969+
{
4970+
"@id": "ex:person2",
4971+
"@type": "ex:Person",
4972+
"ex:preferences": {
4973+
"@list": [
4974+
"coffee",
4975+
"tea",
4976+
"coffee",
4977+
"tea",
4978+
"tea"
4979+
]
4980+
}
4981+
}
4982+
]
4983+
}</pre>
4984+
</div>
4985+
</div>
4986+
</aside>
48194987
</section>
48204988
</section>
48214989

0 commit comments

Comments
 (0)