Skip to main content

shifty_parse/
vocab.rs

1//! IRI constants for the SHACL, RDF, and RDFS vocabularies.
2//!
3//! `*_REF` constants are `NamedNodeRef` for graph lookups; the owned helpers are
4//! for building paths in the IR.
5
6use oxrdf::{NamedNode, NamedNodeRef};
7
8pub const SH: &str = "http://www.w3.org/ns/shacl#";
9pub const RDF: &str = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
10pub const RDFS: &str = "http://www.w3.org/2000/01/rdf-schema#";
11pub const OWL: &str = "http://www.w3.org/2002/07/owl#";
12
13macro_rules! iri {
14    ($name:ident, $iri:expr) => {
15        pub const $name: NamedNodeRef<'static> = NamedNodeRef::new_unchecked($iri);
16    };
17}
18
19// rdf / rdfs
20iri!(RDF_TYPE, "http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
21iri!(
22    RDF_FIRST,
23    "http://www.w3.org/1999/02/22-rdf-syntax-ns#first"
24);
25iri!(RDF_REST, "http://www.w3.org/1999/02/22-rdf-syntax-ns#rest");
26iri!(RDF_NIL, "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil");
27iri!(RDFS_CLASS, "http://www.w3.org/2000/01/rdf-schema#Class");
28iri!(
29    RDFS_SUBCLASSOF,
30    "http://www.w3.org/2000/01/rdf-schema#subClassOf"
31);
32iri!(OWL_CLASS, "http://www.w3.org/2002/07/owl#Class");
33iri!(OWL_IMPORTS, "http://www.w3.org/2002/07/owl#imports");
34
35// shape types
36iri!(SH_NODE_SHAPE, "http://www.w3.org/ns/shacl#NodeShape");
37iri!(
38    SH_PROPERTY_SHAPE,
39    "http://www.w3.org/ns/shacl#PropertyShape"
40);
41
42// targets
43iri!(SH_TARGET_NODE, "http://www.w3.org/ns/shacl#targetNode");
44iri!(SH_TARGET_CLASS, "http://www.w3.org/ns/shacl#targetClass");
45iri!(
46    SH_TARGET_SUBJECTS_OF,
47    "http://www.w3.org/ns/shacl#targetSubjectsOf"
48);
49iri!(
50    SH_TARGET_OBJECTS_OF,
51    "http://www.w3.org/ns/shacl#targetObjectsOf"
52);
53iri!(SH_TARGET, "http://www.w3.org/ns/shacl#target");
54iri!(SH_SELECT, "http://www.w3.org/ns/shacl#select");
55iri!(SH_ASK, "http://www.w3.org/ns/shacl#ask");
56
57// paths
58iri!(SH_PATH, "http://www.w3.org/ns/shacl#path");
59iri!(SH_INVERSE_PATH, "http://www.w3.org/ns/shacl#inversePath");
60iri!(
61    SH_ALTERNATIVE_PATH,
62    "http://www.w3.org/ns/shacl#alternativePath"
63);
64iri!(
65    SH_ZERO_OR_MORE_PATH,
66    "http://www.w3.org/ns/shacl#zeroOrMorePath"
67);
68iri!(
69    SH_ONE_OR_MORE_PATH,
70    "http://www.w3.org/ns/shacl#oneOrMorePath"
71);
72iri!(
73    SH_ZERO_OR_ONE_PATH,
74    "http://www.w3.org/ns/shacl#zeroOrOnePath"
75);
76
77// value-type / facet constraints
78iri!(SH_CLASS, "http://www.w3.org/ns/shacl#class");
79iri!(SH_DATATYPE, "http://www.w3.org/ns/shacl#datatype");
80iri!(SH_NODE_KIND, "http://www.w3.org/ns/shacl#nodeKind");
81iri!(SH_MIN_EXCLUSIVE, "http://www.w3.org/ns/shacl#minExclusive");
82iri!(SH_MIN_INCLUSIVE, "http://www.w3.org/ns/shacl#minInclusive");
83iri!(SH_MAX_EXCLUSIVE, "http://www.w3.org/ns/shacl#maxExclusive");
84iri!(SH_MAX_INCLUSIVE, "http://www.w3.org/ns/shacl#maxInclusive");
85iri!(SH_MIN_LENGTH, "http://www.w3.org/ns/shacl#minLength");
86iri!(SH_MAX_LENGTH, "http://www.w3.org/ns/shacl#maxLength");
87iri!(SH_PATTERN, "http://www.w3.org/ns/shacl#pattern");
88iri!(SH_FLAGS, "http://www.w3.org/ns/shacl#flags");
89iri!(SH_LANGUAGE_IN, "http://www.w3.org/ns/shacl#languageIn");
90iri!(SH_UNIQUE_LANG, "http://www.w3.org/ns/shacl#uniqueLang");
91
92// cardinality
93iri!(SH_MIN_COUNT, "http://www.w3.org/ns/shacl#minCount");
94iri!(SH_MAX_COUNT, "http://www.w3.org/ns/shacl#maxCount");
95
96// property pairs
97iri!(SH_EQUALS, "http://www.w3.org/ns/shacl#equals");
98iri!(SH_DISJOINT, "http://www.w3.org/ns/shacl#disjoint");
99iri!(SH_LESS_THAN, "http://www.w3.org/ns/shacl#lessThan");
100iri!(
101    SH_LESS_THAN_OR_EQUALS,
102    "http://www.w3.org/ns/shacl#lessThanOrEquals"
103);
104
105// logical
106iri!(SH_NOT, "http://www.w3.org/ns/shacl#not");
107iri!(SH_AND, "http://www.w3.org/ns/shacl#and");
108iri!(SH_OR, "http://www.w3.org/ns/shacl#or");
109iri!(SH_XONE, "http://www.w3.org/ns/shacl#xone");
110
111// shape-based
112iri!(SH_NODE, "http://www.w3.org/ns/shacl#node");
113iri!(SH_PROPERTY, "http://www.w3.org/ns/shacl#property");
114iri!(
115    SH_QUALIFIED_VALUE_SHAPE,
116    "http://www.w3.org/ns/shacl#qualifiedValueShape"
117);
118iri!(
119    SH_QUALIFIED_MIN_COUNT,
120    "http://www.w3.org/ns/shacl#qualifiedMinCount"
121);
122iri!(
123    SH_QUALIFIED_MAX_COUNT,
124    "http://www.w3.org/ns/shacl#qualifiedMaxCount"
125);
126iri!(
127    SH_QUALIFIED_VALUE_SHAPES_DISJOINT,
128    "http://www.w3.org/ns/shacl#qualifiedValueShapesDisjoint"
129);
130
131// other
132iri!(SH_CLOSED, "http://www.w3.org/ns/shacl#closed");
133iri!(
134    SH_IGNORED_PROPERTIES,
135    "http://www.w3.org/ns/shacl#ignoredProperties"
136);
137iri!(SH_HAS_VALUE, "http://www.w3.org/ns/shacl#hasValue");
138iri!(SH_IN, "http://www.w3.org/ns/shacl#in");
139iri!(SH_DEACTIVATED, "http://www.w3.org/ns/shacl#deactivated");
140
141// node-kind values
142iri!(SH_IRI, "http://www.w3.org/ns/shacl#IRI");
143iri!(SH_BLANK_NODE, "http://www.w3.org/ns/shacl#BlankNode");
144iri!(SH_LITERAL, "http://www.w3.org/ns/shacl#Literal");
145iri!(
146    SH_BLANK_NODE_OR_IRI,
147    "http://www.w3.org/ns/shacl#BlankNodeOrIRI"
148);
149iri!(
150    SH_BLANK_NODE_OR_LITERAL,
151    "http://www.w3.org/ns/shacl#BlankNodeOrLiteral"
152);
153iri!(SH_IRI_OR_LITERAL, "http://www.w3.org/ns/shacl#IRIOrLiteral");
154
155// AF (recognized for diagnostics)
156iri!(SH_SPARQL, "http://www.w3.org/ns/shacl#sparql");
157iri!(SH_RULE, "http://www.w3.org/ns/shacl#rule");
158
159// AF functions (SHACL-AF §4.3)
160iri!(SH_PARAMETER, "http://www.w3.org/ns/shacl#parameter");
161iri!(SH_NAME, "http://www.w3.org/ns/shacl#name");
162iri!(
163    SH_SPARQL_FUNCTION,
164    "http://www.w3.org/ns/shacl#SPARQLFunction"
165);
166
167// AF custom constraint components (SHACL §6.2–6.3)
168iri!(
169    SH_CONSTRAINT_COMPONENT,
170    "http://www.w3.org/ns/shacl#ConstraintComponent"
171);
172iri!(SH_VALIDATOR, "http://www.w3.org/ns/shacl#validator");
173iri!(
174    SH_NODE_VALIDATOR,
175    "http://www.w3.org/ns/shacl#nodeValidator"
176);
177iri!(
178    SH_PROPERTY_VALIDATOR,
179    "http://www.w3.org/ns/shacl#propertyValidator"
180);
181iri!(SH_OPTIONAL, "http://www.w3.org/ns/shacl#optional");
182
183// AF expression constraints (SHACL-AF §5)
184iri!(SH_EXPRESSION, "http://www.w3.org/ns/shacl#expression");
185
186// AF node expressions (SHACL-AF §6)
187iri!(SH_FILTER_SHAPE, "http://www.w3.org/ns/shacl#filterShape");
188iri!(SH_NODES, "http://www.w3.org/ns/shacl#nodes");
189iri!(SH_INTERSECTION, "http://www.w3.org/ns/shacl#intersection");
190iri!(SH_UNION, "http://www.w3.org/ns/shacl#union");
191
192// AF rules (SHACL-AF §4)
193iri!(SH_THIS, "http://www.w3.org/ns/shacl#this");
194iri!(SH_SUBJECT, "http://www.w3.org/ns/shacl#subject");
195iri!(SH_PREDICATE, "http://www.w3.org/ns/shacl#predicate");
196iri!(SH_OBJECT, "http://www.w3.org/ns/shacl#object");
197iri!(SH_CONDITION, "http://www.w3.org/ns/shacl#condition");
198iri!(SH_ORDER, "http://www.w3.org/ns/shacl#order");
199iri!(SH_CONSTRUCT, "http://www.w3.org/ns/shacl#construct");
200iri!(SH_PREFIXES, "http://www.w3.org/ns/shacl#prefixes");
201iri!(SH_DECLARE, "http://www.w3.org/ns/shacl#declare");
202iri!(SH_PREFIX, "http://www.w3.org/ns/shacl#prefix");
203iri!(SH_NAMESPACE, "http://www.w3.org/ns/shacl#namespace");
204
205// validation report vocabulary
206iri!(
207    SH_VALIDATION_REPORT,
208    "http://www.w3.org/ns/shacl#ValidationReport"
209);
210iri!(
211    SH_VALIDATION_RESULT,
212    "http://www.w3.org/ns/shacl#ValidationResult"
213);
214iri!(SH_CONFORMS, "http://www.w3.org/ns/shacl#conforms");
215iri!(SH_RESULT, "http://www.w3.org/ns/shacl#result");
216iri!(SH_FOCUS_NODE, "http://www.w3.org/ns/shacl#focusNode");
217iri!(SH_RESULT_PATH, "http://www.w3.org/ns/shacl#resultPath");
218iri!(SH_VALUE, "http://www.w3.org/ns/shacl#value");
219iri!(
220    SH_RESULT_SEVERITY,
221    "http://www.w3.org/ns/shacl#resultSeverity"
222);
223iri!(
224    SH_SOURCE_CONSTRAINT_COMPONENT,
225    "http://www.w3.org/ns/shacl#sourceConstraintComponent"
226);
227iri!(SH_SOURCE_SHAPE, "http://www.w3.org/ns/shacl#sourceShape");
228iri!(SH_INFO, "http://www.w3.org/ns/shacl#Info");
229iri!(SH_WARNING, "http://www.w3.org/ns/shacl#Warning");
230iri!(SH_VIOLATION, "http://www.w3.org/ns/shacl#Violation");
231iri!(SH_SEVERITY, "http://www.w3.org/ns/shacl#severity");
232iri!(SH_MESSAGE, "http://www.w3.org/ns/shacl#message");
233iri!(
234    SH_RESULT_MESSAGE,
235    "http://www.w3.org/ns/shacl#resultMessage"
236);
237
238// constraint components
239iri!(
240    SH_CC_SPARQL,
241    "http://www.w3.org/ns/shacl#SPARQLConstraintComponent"
242);
243iri!(
244    SH_CC_EXPRESSION,
245    "http://www.w3.org/ns/shacl#ExpressionConstraintComponent"
246);
247iri!(
248    SH_CC_CLASS,
249    "http://www.w3.org/ns/shacl#ClassConstraintComponent"
250);
251iri!(
252    SH_CC_DATATYPE,
253    "http://www.w3.org/ns/shacl#DatatypeConstraintComponent"
254);
255iri!(
256    SH_CC_NODE_KIND,
257    "http://www.w3.org/ns/shacl#NodeKindConstraintComponent"
258);
259iri!(
260    SH_CC_MIN_COUNT,
261    "http://www.w3.org/ns/shacl#MinCountConstraintComponent"
262);
263iri!(
264    SH_CC_MAX_COUNT,
265    "http://www.w3.org/ns/shacl#MaxCountConstraintComponent"
266);
267iri!(
268    SH_CC_MIN_EXCLUSIVE,
269    "http://www.w3.org/ns/shacl#MinExclusiveConstraintComponent"
270);
271iri!(
272    SH_CC_MIN_INCLUSIVE,
273    "http://www.w3.org/ns/shacl#MinInclusiveConstraintComponent"
274);
275iri!(
276    SH_CC_MAX_EXCLUSIVE,
277    "http://www.w3.org/ns/shacl#MaxExclusiveConstraintComponent"
278);
279iri!(
280    SH_CC_MAX_INCLUSIVE,
281    "http://www.w3.org/ns/shacl#MaxInclusiveConstraintComponent"
282);
283iri!(
284    SH_CC_MIN_LENGTH,
285    "http://www.w3.org/ns/shacl#MinLengthConstraintComponent"
286);
287iri!(
288    SH_CC_MAX_LENGTH,
289    "http://www.w3.org/ns/shacl#MaxLengthConstraintComponent"
290);
291iri!(
292    SH_CC_PATTERN,
293    "http://www.w3.org/ns/shacl#PatternConstraintComponent"
294);
295iri!(
296    SH_CC_AND,
297    "http://www.w3.org/ns/shacl#AndConstraintComponent"
298);
299iri!(SH_CC_OR, "http://www.w3.org/ns/shacl#OrConstraintComponent");
300iri!(
301    SH_CC_NOT,
302    "http://www.w3.org/ns/shacl#NotConstraintComponent"
303);
304iri!(
305    SH_CC_XONE,
306    "http://www.w3.org/ns/shacl#XoneConstraintComponent"
307);
308iri!(
309    SH_CC_NODE,
310    "http://www.w3.org/ns/shacl#NodeConstraintComponent"
311);
312iri!(
313    SH_CC_HAS_VALUE,
314    "http://www.w3.org/ns/shacl#HasValueConstraintComponent"
315);
316iri!(SH_CC_IN, "http://www.w3.org/ns/shacl#InConstraintComponent");
317iri!(
318    SH_CC_CLOSED,
319    "http://www.w3.org/ns/shacl#ClosedConstraintComponent"
320);
321iri!(
322    SH_CC_EQUALS,
323    "http://www.w3.org/ns/shacl#EqualsConstraintComponent"
324);
325iri!(
326    SH_CC_DISJOINT,
327    "http://www.w3.org/ns/shacl#DisjointConstraintComponent"
328);
329iri!(
330    SH_CC_LESS_THAN,
331    "http://www.w3.org/ns/shacl#LessThanConstraintComponent"
332);
333iri!(
334    SH_CC_LESS_THAN_OR_EQUALS,
335    "http://www.w3.org/ns/shacl#LessThanOrEqualsConstraintComponent"
336);
337iri!(
338    SH_CC_LANGUAGE_IN,
339    "http://www.w3.org/ns/shacl#LanguageInConstraintComponent"
340);
341iri!(
342    SH_CC_UNIQUE_LANG,
343    "http://www.w3.org/ns/shacl#UniqueLangConstraintComponent"
344);
345iri!(
346    SH_CC_QUALIFIED_MIN_COUNT,
347    "http://www.w3.org/ns/shacl#QualifiedMinCountConstraintComponent"
348);
349iri!(
350    SH_CC_QUALIFIED_MAX_COUNT,
351    "http://www.w3.org/ns/shacl#QualifiedMaxCountConstraintComponent"
352);
353
354/// SHACL Core constraint components that this engine already implements
355/// natively. Some shapes graphs (e.g. closures that embed the SHACL/DASH
356/// vocabularies themselves, not just user shapes) carry RDF triples
357/// describing these components' own `sh:parameter`/`sh:validator` — the same
358/// shape used to declare a genuine SHACL-AF custom component (§6.3). Without
359/// this exclusion list, the custom-component collector would treat SHACL's
360/// own vocabulary as user-defined components and re-run every native
361/// constraint a second time through the (much slower) generic SPARQL
362/// fallback validator.
363pub const NATIVE_CONSTRAINT_COMPONENTS: &[NamedNodeRef<'static>] = &[
364    SH_CC_SPARQL,
365    SH_CC_EXPRESSION,
366    SH_CC_CLASS,
367    SH_CC_DATATYPE,
368    SH_CC_NODE_KIND,
369    SH_CC_MIN_COUNT,
370    SH_CC_MAX_COUNT,
371    SH_CC_MIN_EXCLUSIVE,
372    SH_CC_MIN_INCLUSIVE,
373    SH_CC_MAX_EXCLUSIVE,
374    SH_CC_MAX_INCLUSIVE,
375    SH_CC_MIN_LENGTH,
376    SH_CC_MAX_LENGTH,
377    SH_CC_PATTERN,
378    SH_CC_AND,
379    SH_CC_OR,
380    SH_CC_NOT,
381    SH_CC_XONE,
382    SH_CC_NODE,
383    SH_CC_HAS_VALUE,
384    SH_CC_IN,
385    SH_CC_CLOSED,
386    SH_CC_EQUALS,
387    SH_CC_DISJOINT,
388    SH_CC_LESS_THAN,
389    SH_CC_LESS_THAN_OR_EQUALS,
390    SH_CC_LANGUAGE_IN,
391    SH_CC_UNIQUE_LANG,
392    SH_CC_QUALIFIED_MIN_COUNT,
393    SH_CC_QUALIFIED_MAX_COUNT,
394];
395
396/// `rdf:type` as an owned node (for path construction).
397pub fn rdf_type() -> NamedNode {
398    NamedNode::new_unchecked(format!("{RDF}type"))
399}
400
401/// `rdfs:subClassOf` as an owned node (for path construction).
402pub fn rdfs_subclassof() -> NamedNode {
403    NamedNode::new_unchecked(format!("{RDFS}subClassOf"))
404}