Skip to content

Commit f97d057

Browse files
committed
RDF syntax for SHACL Rules
1 parent a7f5f90 commit f97d057

7 files changed

Lines changed: 1123 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+
.

0 commit comments

Comments
 (0)