Skip to content

Commit 2133631

Browse files
committed
chore: add examples to list constraints
1 parent ba60f54 commit 2133631

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
@@ -4524,7 +4524,7 @@ <h4>sh:uniqueLang</h4>
45244524
<h3>List Constraint Components</h3>
45254525
<p>
45264526
The constraint components in this section apply to <a>value nodes</a> that are <a href="#syntax-rule-SHACL-list">SHACL lists</a>.
4527-
They specify conditions on the structure, length, and members of RDF lists.
4527+
They specify conditions on the structure, length, and members of SHACL lists.
45284528
</p>
45294529

45304530
<section id="MemberShapeConstraintComponent">
@@ -4555,7 +4555,7 @@ <h4>sh:memberShape</h4>
45554555
<div class="def-text-body" data-validator="MemberShape">
45564556
Let <code>$memberShape</code> be a <a>parameter value</a> for <code>sh:memberShape</code>.
45574557
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>.
4558-
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>.
4558+
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>.
45594559
</div>
45604560
</div>
45614561
<p><em>The remainder of this section is informative.</em></p>
@@ -4566,6 +4566,9 @@ <h4>sh:memberShape</h4>
45664566
<p>
45674567
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>.
45684568
</p>
4569+
<p>
4570+
In the following example, all values of the property <code>ex:speakerOrder</code> must be SHACL lists with members that are IRIs.
4571+
</p>
45694572
<aside class="example">
45704573
<div class="shapes-graph">
45714574
<div class="turtle">
@@ -4577,18 +4580,13 @@ <h4>sh:memberShape</h4>
45774580
sh:memberShape [
45784581
sh:nodeKind sh:IRI ;
45794582
] ;
4580-
sh:maxCount 1 ;
45814583
] .
45824584
</div>
45834585
<div class="jsonld">
45844586
<pre class="jsonld">{
45854587
"@id": "ex:AgendaShape",
45864588
"@type": "sh:NodeShape",
45874589
"sh:property": {
4588-
"sh:maxCount": {
4589-
"@type": "xsd:integer",
4590-
"@value": "1"
4591-
},
45924590
"sh:memberShape": {
45934591
"sh:nodeKind": {
45944592
"@id": "sh:IRI"
@@ -4648,48 +4646,6 @@ <h4>sh:memberShape</h4>
46484646
}
46494647
}
46504648
]
4651-
}</pre>
4652-
</div>
4653-
</div>
4654-
<div class="validation-report">
4655-
<div class="turtle">
4656-
[] a sh:ValidationReport ;
4657-
sh:conforms false ;
4658-
sh:result [
4659-
a sh:ValidationResult ;
4660-
sh:focusNode ex:agenda2 ;
4661-
sh:resultMessage "List member does not have the required node kind sh:IRI." ;
4662-
sh:resultPath ex:speakerOrder ;
4663-
sh:resultSeverity sh:Violation ;
4664-
sh:sourceConstraintComponent sh:MemberShapeConstraintComponent ;
4665-
sh:sourceShape ex:AgendaShape ;
4666-
sh:value "Charlie" ;
4667-
] .
4668-
</div>
4669-
<div class="jsonld">
4670-
<pre class="jsonld">{
4671-
"@type": "sh:ValidationReport",
4672-
"sh:conforms": false,
4673-
"sh:result": {
4674-
"@type": "sh:ValidationResult",
4675-
"sh:focusNode": {
4676-
"@id": "ex:agenda2"
4677-
},
4678-
"sh:resultMessage": "List member does not have the required node kind sh:IRI.",
4679-
"sh:resultPath": {
4680-
"@id": "ex:speakerOrder"
4681-
},
4682-
"sh:resultSeverity": {
4683-
"@id": "sh:Violation"
4684-
},
4685-
"sh:sourceConstraintComponent": {
4686-
"@id": "sh:MemberShapeConstraintComponent"
4687-
},
4688-
"sh:sourceShape": {
4689-
"@id": "ex:AgendaShape"
4690-
},
4691-
"sh:value": "Charlie"
4692-
}
46934649
}</pre>
46944650
</div>
46954651
</div>
@@ -4729,6 +4685,74 @@ <h4>sh:minListLength</h4>
47294685
there is a <a>validation result</a>.
47304686
</div>
47314687
</div>
4688+
<p><em>The remainder of this section is informative.</em></p>
4689+
<p>
4690+
In the following example, all values of the property <code>ex:skills</code> must be SHACL lists with at least 1 member.
4691+
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>.
4692+
</p>
4693+
<aside class="example">
4694+
<div class="shapes-graph">
4695+
<div class="turtle">
4696+
ex:PersonShape
4697+
a sh:NodeShape ;
4698+
<span class="target-can-be-skipped">sh:targetClass ex:Person ;</span>
4699+
sh:property [
4700+
sh:path ex:skills ;
4701+
sh:minListLength 1 ;
4702+
] .
4703+
</div>
4704+
<div class="jsonld">
4705+
<pre class="jsonld">{
4706+
"@id": "ex:PersonShape",
4707+
"@type": "sh:NodeShape",
4708+
"sh:property": {
4709+
"sh:minListLength": {
4710+
"@type": "xsd:integer",
4711+
"@value": "1"
4712+
},
4713+
"sh:path": {
4714+
"@id": "ex:skills"
4715+
}
4716+
},
4717+
"sh:targetClass": {
4718+
"@id": "ex:Person"
4719+
}
4720+
}</pre>
4721+
</div>
4722+
</div>
4723+
<div class="data-graph">
4724+
<div class="turtle">
4725+
ex:person1 a ex:Person ;
4726+
ex:skills ( "programming" "design" ) .
4727+
4728+
<span class="focus-node-error">ex:person2</span> a ex:Person ;
4729+
ex:skills () .
4730+
</div>
4731+
<div class="jsonld">
4732+
<pre class="jsonld">{
4733+
"@graph": [
4734+
{
4735+
"@id": "ex:person1",
4736+
"@type": "ex:Person",
4737+
"ex:skills": {
4738+
"@list": [
4739+
"programming",
4740+
"design"
4741+
]
4742+
}
4743+
},
4744+
{
4745+
"@id": "ex:person2",
4746+
"@type": "ex:Person",
4747+
"ex:skills": {
4748+
"@list": []
4749+
}
4750+
}
4751+
]
4752+
}</pre>
4753+
</div>
4754+
</div>
4755+
</aside>
47324756
</section>
47334757

47344758
<section id="MaxListLengthConstraintComponent">
@@ -4764,6 +4788,78 @@ <h4>sh:maxListLength</h4>
47644788
there is a <a>validation result</a>.
47654789
</div>
47664790
</div>
4791+
<p><em>The remainder of this section is informative.</em></p>
4792+
<p>
4793+
In the following example, all values of the property <code>ex:hobbies</code> must be SHACL lists with at most 2 members.
4794+
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>.
4795+
</p>
4796+
<aside class="example">
4797+
<div class="shapes-graph">
4798+
<div class="turtle">
4799+
ex:PersonShape
4800+
a sh:NodeShape ;
4801+
<span class="target-can-be-skipped">sh:targetClass ex:Person ;</span>
4802+
sh:property [
4803+
sh:path ex:hobbies ;
4804+
sh:maxListLength 2 ;
4805+
] .
4806+
</div>
4807+
<div class="jsonld">
4808+
<pre class="jsonld">{
4809+
"@id": "ex:PersonShape",
4810+
"@type": "sh:NodeShape",
4811+
"sh:property": {
4812+
"sh:maxListLength": {
4813+
"@type": "xsd:integer",
4814+
"@value": "2"
4815+
},
4816+
"sh:path": {
4817+
"@id": "ex:hobbies"
4818+
}
4819+
},
4820+
"sh:targetClass": {
4821+
"@id": "ex:Person"
4822+
}
4823+
}</pre>
4824+
</div>
4825+
</div>
4826+
<div class="data-graph">
4827+
<div class="turtle">
4828+
ex:person1 a ex:Person ;
4829+
ex:hobbies ( "reading" "writing" ) .
4830+
4831+
<span class="focus-node-error">ex:person2</span> a ex:Person ;
4832+
ex:hobbies ( "reading" "writing" "swimming" ) .
4833+
</div>
4834+
<div class="jsonld">
4835+
<pre class="jsonld">{
4836+
"@graph": [
4837+
{
4838+
"@id": "ex:person1",
4839+
"@type": "ex:Person",
4840+
"ex:hobbies": {
4841+
"@list": [
4842+
"reading",
4843+
"writing"
4844+
]
4845+
}
4846+
},
4847+
{
4848+
"@id": "ex:person2",
4849+
"@type": "ex:Person",
4850+
"ex:hobbies": {
4851+
"@list": [
4852+
"reading",
4853+
"writing",
4854+
"swimming"
4855+
]
4856+
}
4857+
}
4858+
]
4859+
}</pre>
4860+
</div>
4861+
</div>
4862+
</aside>
47674863
</section>
47684864

47694865
<section id="UniqueMembersConstraintComponent">
@@ -4800,11 +4896,83 @@ <h4>sh:uniqueMembers</h4>
48004896
</div>
48014897
<p><em>The remainder of this section is informative.</em></p>
48024898
<p>
4803-
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>.
4899+
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>.
48044900
</p>
48054901
<p>
48064902
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>.
48074903
</p>
4904+
<p>
4905+
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.
4906+
</p>
4907+
<aside class="example">
4908+
<div class="shapes-graph">
4909+
<div class="turtle">
4910+
ex:PersonShape
4911+
a sh:NodeShape ;
4912+
<span class="target-can-be-skipped">sh:targetClass ex:Person ;</span>
4913+
sh:property [
4914+
sh:path ex:preferences ;
4915+
sh:uniqueMembers true ;
4916+
] .
4917+
</div>
4918+
<div class="jsonld">
4919+
<pre class="jsonld">{
4920+
"@id": "ex:PersonShape",
4921+
"@type": "sh:NodeShape",
4922+
"sh:property": {
4923+
"sh:uniqueMembers": {
4924+
"@type": "xsd:boolean",
4925+
"@value": "true"
4926+
},
4927+
"sh:path": {
4928+
"@id": "ex:preferences"
4929+
}
4930+
},
4931+
"sh:targetClass": {
4932+
"@id": "ex:Person"
4933+
}
4934+
}</pre>
4935+
</div>
4936+
</div>
4937+
<div class="data-graph">
4938+
<div class="turtle">
4939+
ex:person1 a ex:Person ;
4940+
ex:preferences ( "coffee" "tea" ) .
4941+
4942+
<span class="focus-node-error">ex:person2</span> a ex:Person ;
4943+
ex:preferences ( "coffee" "tea" "coffee" "tea" "tea" ) .
4944+
</div>
4945+
<div class="jsonld">
4946+
<pre class="jsonld">{
4947+
"@graph": [
4948+
{
4949+
"@id": "ex:person1",
4950+
"@type": "ex:Person",
4951+
"ex:preferences": {
4952+
"@list": [
4953+
"coffee",
4954+
"tea"
4955+
]
4956+
}
4957+
},
4958+
{
4959+
"@id": "ex:person2",
4960+
"@type": "ex:Person",
4961+
"ex:preferences": {
4962+
"@list": [
4963+
"coffee",
4964+
"tea",
4965+
"coffee",
4966+
"tea",
4967+
"tea"
4968+
]
4969+
}
4970+
}
4971+
]
4972+
}</pre>
4973+
</div>
4974+
</div>
4975+
</aside>
48084976
</section>
48094977
</section>
48104978

0 commit comments

Comments
 (0)