@@ -481,6 +481,7 @@ <h3>Terminology</h3>
481
481
< dfn data-cite ="shacl12-core#dfn-conform " data-lt ="conform|conforms "> conform</ dfn > ,
482
482
< dfn data-cite ="shacl12-core#dfn-conformance-check " data-lt ="conformance check "> conformance check</ dfn > ,
483
483
< dfn data-cite ="shacl12-core#dfn-failure " data-lt ="failure|failures "> failure</ dfn > ,
484
+ < dfn data-cite ="shacl12-core#dfn-validation "> validation</ dfn > ,
484
485
< dfn data-cite ="shacl12-core#dfn-shacl-instance " data-lt ="shacl instance "> SHACL instance</ dfn > ,
485
486
< dfn data-cite ="shacl12-core#dfn-shacl-subclass " data-lt ="shacl subclass "> SHACL subclass</ dfn > ,
486
487
< dfn data-cite ="shacl12-core#dfn-shacl-type " data-lt ="shacl type "> SHACL type</ dfn > ,
@@ -557,12 +558,11 @@ <h3>Document Conventions</h3>
557
558
</ section >
558
559
</ section >
559
560
560
- < section id ="getting-started ">
561
+ < section id ="getting-started " class =" informative " >
561
562
< h2 > Getting started with Node Expressions</ h2 >
562
- < p > < em > This section is informative.</ em > </ p >
563
563
< p >
564
564
A SHACL < a > shapes graph</ a > can declare node expressions as values of various properties where dynamic computation is useful,
565
- such as < code > sh:targetNode</ code > , < code > sh:values</ code > and < code > sh:deactivated</ code > .
565
+ such as < code > sh:targetNode</ code > , < code > sh:values</ code > , and < code > sh:deactivated</ code > .
566
566
A node expression is represented by an RDF node and can be evaluated to produce a list of < a > output nodes</ a > .
567
567
For example, when used at < code > sh:targetNode</ code > , a node expression produces the list
568
568
of target nodes of a < a > shape</ a > .
@@ -2647,6 +2647,153 @@ <h3>sh:nodeByExpression</h3>
2647
2647
2648
2648
</ section >
2649
2649
2650
+ < section id ="dynamic-shacl ">
2651
+ < h2 > Dynamic SHACL</ h2 >
2652
+ < p >
2653
+ This section defines < dfn > Dynamic SHACL</ dfn > as a dialect of SHACL that some implementations MAY support.
2654
+ </ p >
2655
+ < p >
2656
+ In Dynamic SHACL any < a > parameter</ a > of a < a > constraint</ a > can be computed using a < a > node expression</ a > ,
2657
+ excluding those that do < em > not</ em > allow < a > blank nodes</ a > (such as < code > sh:node</ code > )
2658
+ but including those that take < a > SHACL lists</ a > as values (such as < code > sh:class</ code > ,
2659
+ < code > sh:datatype</ code > , and < code > sh:in</ code > ).
2660
+ During < a > validation</ a > , such < a > node expressions</ a > are evaluated in the < a > data graph</ a > ,
2661
+ using the current < a > focus node</ a > .
2662
+ The resulting < a > nodes</ a > will be used as < a > parameters</ a > for the < a > constraint</ a > .
2663
+ </ p >
2664
+ < section class ="informative ">
2665
+ < h3 > Example: Dynamic Minimum Age of Presidents</ h3 >
2666
+ < p >
2667
+ As a use case of < a > Dynamic SHACL</ a > , assume we want to express that the legal minimum age
2668
+ of a president is 18 unless the country is USA, where it is 35.
2669
+ </ p >
2670
+ < aside class ="example " title ="Example of Dynamic SHACL using a node expression at sh:minInclusive ">
2671
+ < div class ="shapes-graph ">
2672
+ < div class ="turtle ">
2673
+ ex:PresidentShape
2674
+ a sh:NodeShape ;
2675
+ sh:targetClass ex:President ;
2676
+ sh:property ex:PresidentShape-age ;
2677
+ .
2678
+ ex:PresidentShape-age
2679
+ a sh:PropertyShape ;
2680
+ sh:path ex:age ;
2681
+ < b > sh:minInclusive [
2682
+ shnex:if [
2683
+ sparql:eq (
2684
+ [ shnex:path ex:country ]
2685
+ ex:USA
2686
+ )
2687
+ ]
2688
+ shnex:then 35 ;
2689
+ shnex:else 18 ;
2690
+ ]</ b > .
2691
+ </ div >
2692
+ < div class ="jsonld ">
2693
+ < pre class ="jsonld ">
2694
+ TODO
2695
+ </ pre >
2696
+ </ div >
2697
+ </ div >
2698
+ </ aside >
2699
+ </ section >
2700
+ < section class ="informative ">
2701
+ < h3 > Example: Dynamic Enumerations</ h3 >
2702
+ < p >
2703
+ As a use case of < a > Dynamic SHACL</ a > , assume the following < a > data graph</ a > .
2704
+ </ p >
2705
+ < aside class ="example " title ="Example data graph with addresses ">
2706
+ < div class ="data-graph ">
2707
+ < div class ="turtle ">
2708
+ ex:ArizonaAddress1
2709
+ a ex:Address ;
2710
+ ex:street "123 John Muir Ave" ;
2711
+ ex:country ex:USA ;
2712
+ ex:state "AZ" ;
2713
+ .
2714
+ ex:QueenslandAddress1
2715
+ a ex:Address ;
2716
+ ex:street "123 Bob Katter Cl" ;
2717
+ ex:country ex:Australia ;
2718
+ ex:state "QLD" ;
2719
+ .
2720
+ </ div >
2721
+ < div class ="jsonld ">
2722
+ < pre class ="jsonld ">
2723
+ TODO
2724
+ </ pre >
2725
+ </ div >
2726
+ </ div >
2727
+ </ aside >
2728
+ < p >
2729
+ We want to express that the valid values of < code > ex:state</ code > depend on the value of < code > ex:country</ code >
2730
+ at the given focus node.
2731
+ For example, the valid values for country < code > ex:USA</ code > would be < code > ( "AL" "AK" "AZ" ... )</ code >
2732
+ while valid values for country < code > ex:Australia</ code > would be < code > ( "ACT" "NSW" "NT" "QLD" "SA" "TAS" "VIC" "WA" )</ code > .
2733
+ This fact can be represented as part of the data:
2734
+ </ p >
2735
+ < aside class ="example " title ="The valid states can be attached to each country ">
2736
+ < div class ="data-graph ">
2737
+ < div class ="turtle ">
2738
+ ex:Australia
2739
+ a ex:Country ;
2740
+ ex:stateCode "ACT",
2741
+ "NSW",
2742
+ "NT",
2743
+ "QLD",
2744
+ "SA",
2745
+ "TAS",
2746
+ "VIC",
2747
+ "WA" ;
2748
+ .
2749
+ ex:USA
2750
+ a ex:Country ;
2751
+ ex:stateCode "AL",
2752
+ "AK",
2753
+ "AZ",
2754
+ "AR" ; # ...
2755
+ .
2756
+ </ div >
2757
+ < div class ="jsonld ">
2758
+ < pre class ="jsonld ">
2759
+ TODO
2760
+ </ pre >
2761
+ </ div >
2762
+ </ div >
2763
+ </ aside >
2764
+ < p >
2765
+ Using this extra information, we can now define a < code > sh:in</ code > constraint using a < a > Path Expression</ a > :
2766
+ </ p >
2767
+ < aside class ="example " title ="Example of Dynamic SHACL using a node expression at sh:in ">
2768
+ < div class ="shapes-graph ">
2769
+ < div class ="turtle ">
2770
+ ex:Address
2771
+ a sh:ShapeClass ;
2772
+ sh:property ex:Address-state ;
2773
+ .
2774
+ ex:Address-state
2775
+ a sh:PropertyShape ;
2776
+ sh:path ex:state ;
2777
+ < b > sh:in [
2778
+ shnex:path ( ex:country ex:stateCode )
2779
+ ]</ b > .
2780
+ </ div >
2781
+ < div class ="jsonld ">
2782
+ < pre class ="jsonld ">
2783
+ TODO
2784
+ </ pre >
2785
+ </ div >
2786
+ </ div >
2787
+ </ aside >
2788
+ < p >
2789
+ During validation, a Dynamic SHACL engine will evaluate the path expression at < code > sh:in</ code >
2790
+ and use the resulting nodes as members of the allowed values.
2791
+ Thus, when the value of < code > ex:country</ code > is < code > ex:USA</ code > , it will look up the
2792
+ state codes that are linked to < code > ex:USA</ code > .
2793
+ </ p >
2794
+ </ section >
2795
+ </ section >
2796
+
2650
2797
< section id ="security ">
2651
2798
< h2 > Security Considerations</ h2 >
2652
2799
< p > TODO</ p >
0 commit comments