Skip to main content

strixonomy_swrl/
builtins.rs

1//! Core SWRL built-ins registry (`swrlb:`).
2
3pub const SWRLB_NS: &str = "http://www.w3.org/2003/11/swrlb#";
4
5/// Built-ins Strixonomy validates and documents for v0.23 (execution may still be partial).
6pub const SUPPORTED_BUILTINS: &[&str] = &[
7    "equal",
8    "notEqual",
9    "lessThan",
10    "lessThanOrEqual",
11    "greaterThan",
12    "greaterThanOrEqual",
13    "add",
14    "subtract",
15    "multiply",
16    "divide",
17    "stringEqualIgnoreCase",
18    "stringConcat",
19    "substring",
20    "stringLength",
21    "contains",
22    "startsWith",
23    "endsWith",
24    "matches",
25    "booleanNot",
26];
27
28pub fn is_supported_builtin(predicate_iri: &str) -> bool {
29    // Require the SWRLB namespace (#363). Foreign IRIs that only share a local name
30    // (e.g. `http://evil.example/equal`) must not validate as supported.
31    let Some(local) = predicate_iri.strip_prefix(SWRLB_NS) else {
32        return false;
33    };
34    SUPPORTED_BUILTINS.contains(&local)
35}
36
37#[allow(dead_code)]
38pub fn builtin_iri(local: &str) -> String {
39    format!("{SWRLB_NS}{local}")
40}