Skip to content

Commit c5ec8c2

Browse files
committed
RDF syntax for SHACL Rules
1 parent 2324310 commit c5ec8c2

7 files changed

Lines changed: 1122 additions & 0 deletions

File tree

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
3+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
4+
5+
PREFIX sparql: <http://www.w3.org/ns/sparql#>
6+
PREFIX sh: <http://www.w3.org/ns/shacl#>
7+
PREFIX srl: <http://www.w3.org/ns/shacl-rules#>
8+
PREFIX srl-sh: <http://www.w3.org/ns/shacl-rules-shapes#>
9+
PREFIX shnex: <http://www.w3.org/ns/shnex#>
10+
11+
#### RDF Term and variables.
12+
13+
## Variables
14+
15+
srl-sh:variableShape rdf:type sh:NodeShape ;
16+
sh:property
17+
[
18+
sh:path srl:varName ;
19+
sh:datatype xsd:string ;
20+
sh:minCount 1 ;
21+
sh:maxCount 1 ;
22+
] .
23+
24+
## RDF Terms (blank nodes exclude syntax usage e.g. as variables)
25+
26+
srl-sh:termShape rdf:type sh:NodeShape ;
27+
sh:name "RDF Term" ;
28+
sh:xone (
29+
srl-sh:blankNodeDataShape
30+
[ sh:nodeKind sh:IRI ]
31+
[ sh:nodeKind sh:Literal ]
32+
[ sh:nodeKind sh:TripleTerm ]
33+
) .
34+
35+
srl-sh:blankNodeDataShape rdf:type sh:NodeShape ;
36+
sh:nodeKind sh:BlankNode ;
37+
sh:not srl-sh:variableShape ;
38+
.
39+
40+
srl-sh:varOrTermShape rdf:type sh:NodeShape ;
41+
sh:name "VarOrTerm" ;
42+
sh:xone ( [ sh:node srl-sh:variableShape ]
43+
[ sh:node srl-sh:termShape ]
44+
) .
45+
46+
srl-sh:varOrIRIShape rdf:type sh:NodeShape ;
47+
sh:name "VarOrIRI" ;
48+
sh:xone ( [ sh:node srl-sh:variableShape ]
49+
[ sh:nodeKind sh:IRI ]
50+
) .
51+
52+
srl-sh:blankNodeOrIRIShape rdf:type sh:NodeShape ;
53+
sh:name "IRIorBlankNode" ;
54+
sh:xone ( [ sh:nodeKind sh:BlankNode ]
55+
[ sh:nodeKind sh:IRI ]
56+
) .
57+
58+
#### Triples
59+
60+
## Symmetric RDF Triple including variables.
61+
srl-sh:tripleShape rdf:type sh:NodeShape ;
62+
sh:property
63+
[ sh:path srl:subject ;
64+
sh:name "Triple subject" ;
65+
sh:minCount 1 ;
66+
sh:maxCount 1 ;
67+
sh:node srl-sh:varOrTermShape
68+
] ;
69+
sh:property
70+
[ sh:path srl:predicate ;
71+
sh:name "Triple predicate" ;
72+
sh:minCount 1 ;
73+
sh:maxCount 1 ;
74+
sh:node srl-sh:varOrIRIShape
75+
] ;
76+
sh:property
77+
[ sh:path srl:object ;
78+
sh:name "Triple object" ;
79+
sh:minCount 1 ;
80+
sh:maxCount 1 ;
81+
sh:node srl-sh:varOrTermShape
82+
] ;
83+
.
84+
85+
## Triple pattern (body)
86+
87+
srl-sh:triplePatternShape rdf:type sh:NodeShape ;
88+
sh:node srl-sh:tripleShape ;
89+
.
90+
91+
# Triple template (head)
92+
srl-sh:tripleTemplateShape rdf:type sh:NodeShape ;
93+
sh:node srl-sh:tripleShape ;
94+
.
95+
96+
## Triple Data (DATA)
97+
98+
srl-sh:tripleDataShape rdf:type sh:NodeShape ;
99+
sh:property
100+
[ sh:path srl:subject ;
101+
sh:name "Data triple subject" ;
102+
sh:minCount 1 ;
103+
sh:maxCount 1 ;
104+
sh:node srl-sh:termShape
105+
] ;
106+
sh:property
107+
[ sh:path srl:predicate ;
108+
sh:name "Data triple predicate" ;
109+
sh:minCount 1 ;
110+
sh:maxCount 1 ;
111+
sh:nodeKind sh:IRI
112+
] ;
113+
sh:property
114+
[ sh:path srl:object ;
115+
sh:name "Data triple object" ;
116+
sh:minCount 1 ;
117+
sh:maxCount 1 ;
118+
sh:node srl-sh:termShape
119+
] ;
120+
.
121+
122+
#### Expressions
123+
124+
srl-sh:expressionShape rdf:type sh:NodeShape ;
125+
## if [ srl:expr [ ...] ]
126+
## sh:property
127+
## [ sh:path srl:expr ;
128+
## sh:minCount 1;
129+
## sh:maxCount 1 ;
130+
## ] ;
131+
.
132+
133+
srl-sh:filterElementShape rdf:type sh:NodeShape ;
134+
sh:property
135+
[ sh:path srl:filter ;
136+
sh:node srl-sh:expressionShape ;
137+
sh:minCount 1 ;
138+
sh:maxCount 1 ;
139+
];
140+
.
141+
142+
srl-sh:assignmentElementShape rdf:type sh:NodeShape ;
143+
sh:property
144+
[ sh:path srl:assign ;
145+
sh:minCount 1;
146+
sh:maxCount 1;
147+
sh:property
148+
[ sh:path srl:assignVar ;
149+
sh:node srl-sh:variableShape ;
150+
sh:minCount 1;
151+
sh:maxCount 1;
152+
];
153+
sh:property
154+
[ sh:path srl:assignValue ;
155+
sh:node srl-sh:expressionShape ;
156+
sh:minCount 1 ;
157+
sh:maxCount 1 ;
158+
];
159+
];
160+
.
161+
162+
srl-sh:negationElementBodyShape rdf:type sh:NodeShape ;
163+
sh:xone (
164+
srl-sh:triplePatternShape
165+
srl-sh:filterElementShape
166+
) .
167+
168+
srl-sh:negationElementShape rdf:type sh:NodeShape ;
169+
sh:property
170+
[ sh:path srl:not ;
171+
sh:memberShape srl-sh:negationElementBodyShape ;
172+
sh:minCount 1 ;
173+
sh:maxCount 1 ;
174+
] .
175+
176+
#### DATA
177+
178+
## In data blocks, allow triple terms for data triples.
179+
180+
srl-sh:dataBlockItemShape rdf:type sh:NodeShape ;
181+
sh:xone (
182+
srl-sh:tripleDataShape
183+
[ sh:nodeKind sh:TripleTerm ]
184+
) .
185+
186+
srl-sh:dataBlockShape rdf:type sh:NodeShape ;
187+
sh:property [
188+
sh:path srl:data ;
189+
sh:memberShape srl-sh:dataBlockItemShape ;
190+
] .
191+
192+
### Rule Elements
193+
194+
srl-sh:ruleBodyElement rdf:type sh:NodeShape ;
195+
sh:xone ( srl-sh:triplePatternShape
196+
srl-sh:filterElementShape
197+
srl-sh:assignmentElementShape
198+
srl-sh:negationElementShape
199+
) .
200+
201+
srl-sh:ruleHeadElement rdf:type sh:NodeShape ;
202+
sh:node srl-sh:tripleTemplateShape
203+
.
204+
205+
#### Rule Shape
206+
207+
srl-sh:ruleHeadShape rdf:type sh:NodeShape ;
208+
sh:property
209+
[ sh:path srl:head ;
210+
sh:memberShape srl-sh:ruleHeadElement ;
211+
sh:maxCount 1;
212+
sh:minCount 1;
213+
] .
214+
215+
srl-sh:ruleBodyShape rdf:type sh:NodeShape ;
216+
sh:property
217+
[ sh:path srl:body ;
218+
sh:memberShape srl-sh:ruleBodyElement;
219+
sh:maxCount 1;
220+
sh:minCount 1;
221+
] .
222+
223+
srl-sh:ruleShape rdf:type sh:NodeShape ;
224+
sh:node srl-sh:ruleHeadShape ;
225+
sh:node srl-sh:ruleBodyShape ;
226+
.
227+
228+
#### Rule Set
229+
230+
srl-sh:ruleSetShape rdf:type sh:NodeShape ;
231+
sh:node srl-sh:dataBlockShape ;
232+
sh:property
233+
[ sh:path srl:rules ;
234+
sh:memberShape srl-sh:ruleShape
235+
];
236+
.
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
PREFIX ex: <http://example.org/>
2+
3+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
4+
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
5+
PREFIX sh: <http://www.w3.org/ns/shacl#>
6+
PREFIX srl: <http://www.w3.org/ns/shacl-rules#>
7+
PREFIX owl: <http://www.w3.org/2002/07/owl#>
8+
PREFIX dc: <http://purl.org/dc/elements/1.1/>
9+
10+
<> a owl:Ontology ;
11+
dc:title "The SHACL Rules Language Vocabulary (SRL)" ;
12+
dc:date "2026-12-31" ;
13+
dc:description "This is the RDF Schema for SHACL Rules." ;
14+
rdfs:seeAlso <https://w3c.org/TR/shacl12-rules> .
15+
16+
#### SHACL Rules Syntax
17+
18+
## -- Classes
19+
20+
srl:RuleSet rdf:type rdfs:Class ;
21+
rdfs:isDefinedBy srl: ;
22+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#dfn-rule-set> ;
23+
rdfs:label "Rule Set" ;
24+
rdfs:comment "The class of rule sets." .
25+
26+
srl:Rule rdf:type rdfs:Class ;
27+
rdfs:isDefinedBy srl: ;
28+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#dfn-rule> ;
29+
rdfs:label "A SHACL Rule" ;
30+
rdfs:comment "The class of SHACL Rules." .
31+
32+
## -- Properties
33+
34+
srl:rules rdf:type rdf:Property ;
35+
rdfs:domain srl:RuleSet ;
36+
# range - list of rules
37+
rdfs:isDefinedBy srl: ;
38+
rdfs:label "Rules of a Rule Set" ;
39+
rdfs:comment "The list of rules of the rule set." .
40+
41+
srl:data rdf:type rdf:Property ;
42+
rdfs:domain srl:RuleSet ;
43+
# range - list
44+
rdfs:isDefinedBy srl: ;
45+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#dfn-data-block> ;
46+
rdfs:label "Data" ;
47+
rdfs:comment "The list of data of the rule set." .
48+
49+
srl:head rdf:type rdf:Property ;
50+
rdfs:domain srl:Rule ;
51+
# range - list of triple templates
52+
rdfs:isDefinedBy srl: ;
53+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#dfn-rule-head> ;
54+
rdfs:label "Rule head" ;
55+
rdfs:comment "The consequent of a rule." .
56+
57+
srl:body rdf:type rdf:Property ;
58+
rdfs:domain srl:Rule ;
59+
# range : list of rule elements
60+
rdfs:isDefinedBy srl: ;
61+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#dfn-rule-body> ;
62+
rdfs:label "Rule body" ;
63+
rdfs:comment "The antecedent of a rule." .
64+
65+
## -- Rule Body
66+
67+
srl:RuleElement rdf:type rdfs:Class ;
68+
rdfs:isDefinedBy srl: ;
69+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#dfn-rule-body-element> ;
70+
rdfs:label "A SHACL Rule Element" ;
71+
rdfs:comment "The class of SHACL Rule Elements." .
72+
73+
srl:TriplePattern rdf:type rdfs:Class ;
74+
rdfs:subClassOf srl:RuleElement ;
75+
rdfs:isDefinedBy srl: ;
76+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#dfn-triple-pattern> ;
77+
rdfs:label "A SHACL Rule Element" ;
78+
rdfs:comment "The class of triple patterns." .
79+
80+
srl:CondidtionElement rdf:type rdfs:Class ;
81+
rdfs:subClassOf srl:RuleElement ;
82+
rdfs:isDefinedBy srl: ;
83+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#dfn-condition-element> ;
84+
rdfs:label "A SHACL Rule condition element" ;
85+
rdfs:comment "The class of SHACL condition elements." .
86+
87+
srl:AssignmentElement rdf:type rdfs:Class ;
88+
rdfs:subClassOf srl:RuleElement ;
89+
rdfs:isDefinedBy srl: ;
90+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#dfn-assignment-element> ;
91+
rdfs:label "A SHACL Rule assignment element" ;
92+
rdf:comment "The class of SHACL assignment elements." .
93+
94+
srl:NegationElement rdf:type rdfs:Class ;
95+
rdfs:subClassOf srl:RuleElement ;
96+
rdfs:isDefinedBy srl: ;
97+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#dfn-negation-element> ;
98+
rdfs:label "A SHACL Rule negation element" ;
99+
rdf:comment "The class of SHACL negation elements." .
100+
101+
## ----
102+
103+
srl:filter rdf:type rdf:Property ;
104+
rdfs:isDefinedBy srl: ;
105+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#rdf-rules-syntax> ;
106+
rdfs:label "filter" ;
107+
rdfs:comment "A filter rule element" .
108+
109+
## @@Remove
110+
srl:assign rdf:type rdf:Property ;
111+
rdfs:isDefinedBy srl: ;
112+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#rdf-rules-syntax> ;
113+
rdfs:label "assign" ;
114+
rdfs:comment "An asssignment rule element" .
115+
116+
117+
srl:assignVar rdf:type rdf:Property ;
118+
rdfs:isDefinedBy srl: ;
119+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#rdf-rules-syntax> ;
120+
rdfs:label "assignment variable" ;
121+
rdfs:comment "The variable of an assignment" .
122+
123+
srl:assignValue rdf:type rdf:Property ;
124+
rdfs:isDefinedBy srl: ;
125+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#rdf-rules-syntax> ;
126+
rdfs:label "addignment value" ;
127+
rdfs:comment "The value or expression for an assignment" .
128+
129+
srl:not rdf:type rdf:Property ;
130+
rdfs:isDefinedBy srl: ;
131+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#rdf-rules-syntax> ;
132+
rdfs:label "negation rule element" ;
133+
rdfs:comment "A negation rule element" .
134+
135+
## ----
136+
137+
srl:subject rdf:type rdf:Property ;
138+
rdfs:isDefinedBy srl: ;
139+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#rdf-rules-syntax> ;
140+
rdfs:range rdfs:Resource ;
141+
rdfs:label "subject" ;
142+
rdfs:comment "The subject of a triple, triple pattern or triple template." .
143+
144+
srl:predicate rdf:type rdf:Property ;
145+
rdfs:isDefinedBy srl: ;
146+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#rdf-rules-syntax> ;
147+
rdfs:range rdfs:Resource ;
148+
rdfs:label "predicate" ;
149+
rdfs:comment "The predicate of a triple, triple pattern or triple template." .
150+
151+
srl:object rdf:type rdf:Property ;
152+
rdfs:isDefinedBy srl: ;
153+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#rdf-rules-syntax> ;
154+
rdfs:range rdfs:Resource ;
155+
rdfs:label "object" ;
156+
rdfs:comment "The object of a triple, triple pattern or triple template." .
157+
158+
srl:varName rdf:type rdf:Property ;
159+
rdfs:isDefinedBy srl: ;
160+
rdfs:isDefinedBy <https://www.w3.org/TR/shacl12-rules/#rdf-rules-syntax> ;
161+
rdfs:label "name of a variable" ;
162+
rdfs:comment "Name of a variable name." .

0 commit comments

Comments
 (0)