From 5452c13eaf363de844b78e98a841248fbf566413 Mon Sep 17 00:00:00 2001 From: Giacomo Citi Date: Sat, 12 Oct 2024 15:32:12 +0200 Subject: [PATCH] extract allowed properties --- dist/compile.n3 | 16 +++++++++++----- rules/compile/core-components-others.n3 | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/dist/compile.n3 b/dist/compile.n3 index 720b5fc..7d8170e 100644 --- a/dist/compile.n3 +++ b/dist/compile.n3 @@ -197,11 +197,20 @@ sh:in this:constraint sh:InConstraintComponent . { ?value this:nodeKind sh:IRI } <= { ?value log:rawType log:Other . ?value log:uri [] }. # ClosedConstraintComponent +{ + ?shape this:allowedProperties ?allowed +} +<= { ?shape a this:Shape ; sh:closed true . (?x { ?shape sh:property [ sh:path ?x ] . ?x this:nodeKind sh:IRI } ?existing) log:collectAllIn [] . (?x { ?shape sh:ignoredProperties [ list:member ?x ]} ?ignored) log:collectAllIn [] . (?existing ?ignored) list:append ?allowed . + +} . + +{ + ?shape this:allowedProperties ?allowed . ?allowed log:localN3String ?allowedString . ("allowed properties are only: %s" ?allowedString) string:format ?message . } @@ -228,10 +237,7 @@ sh:in this:constraint sh:InConstraintComponent . } . { - ?shape a this:Shape ; sh:closed true . - (?x { ?shape sh:property [ sh:path ?x ] . ?x this:nodeKind sh:IRI } ?existing) log:collectAllIn [] . - (?x { ?shape sh:ignoredProperties [ list:member ?x ]} ?ignored) log:collectAllIn [] . - (?existing ?ignored) list:append ?allowed . + ?shape this:allowedProperties ?allowed . } => { @@ -240,7 +246,7 @@ sh:in this:constraint sh:InConstraintComponent . } <= { - ?node ?property ?value . + ?node ?property [] . ?allowed list:notMember ?property . } . } . diff --git a/rules/compile/core-components-others.n3 b/rules/compile/core-components-others.n3 index 04da071..3b0aa1e 100644 --- a/rules/compile/core-components-others.n3 +++ b/rules/compile/core-components-others.n3 @@ -10,11 +10,20 @@ { ?value this:nodeKind sh:IRI } <= { ?value log:rawType log:Other . ?value log:uri [] }. # ClosedConstraintComponent +{ + ?shape this:allowedProperties ?allowed +} +<= { ?shape a this:Shape ; sh:closed true . (?x { ?shape sh:property [ sh:path ?x ] . ?x this:nodeKind sh:IRI } ?existing) log:collectAllIn [] . (?x { ?shape sh:ignoredProperties [ list:member ?x ]} ?ignored) log:collectAllIn [] . (?existing ?ignored) list:append ?allowed . + +} . + +{ + ?shape this:allowedProperties ?allowed . ?allowed log:localN3String ?allowedString . ("allowed properties are only: %s" ?allowedString) string:format ?message . } @@ -41,10 +50,7 @@ } . { - ?shape a this:Shape ; sh:closed true . - (?x { ?shape sh:property [ sh:path ?x ] . ?x this:nodeKind sh:IRI } ?existing) log:collectAllIn [] . - (?x { ?shape sh:ignoredProperties [ list:member ?x ]} ?ignored) log:collectAllIn [] . - (?existing ?ignored) list:append ?allowed . + ?shape this:allowedProperties ?allowed . } => { @@ -53,7 +59,7 @@ } <= { - ?node ?property ?value . + ?node ?property [] . ?allowed list:notMember ?property . } . } .