How do you decide on which part of the OR failed to print your expected
message? I mean, technically also the first part lead to FALSE, so we
could easily also decide on printing an assigned message to that part -
doesn't exist in your case, but is also a reason why the validation fails.
Or do you expect all messages being propagated up to the root node which
failed?
On 11.01.23 23:02, Kyle Lawlor-Bagcal wrote:
Hello,
I'm interested to know if there is a way to configure the apache jena
shacl cli tool to output the values of sh:message or sh:resultMessage.
I have a property shape where I tried adding contextual info into
sh:message/sh:resultMessage. I would like to see this info in the
output from the shacl cli in the case of failed validation. Here is an
minimal example to show the situation, in case I'm just doing
something wrong.
schema.ttl:
@prefix schema: <http://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix regen: <http://regen.network/> .
regen:ProjectPageShape a sh:NodeShape ;
sh:targetClass regen:Project-Page ;
sh:or (
[ sh:not
[ sh:path regen:landStewardStory ;
sh:minCount 1 ;
sh:maxCount 1
]
]
[
sh:and (
[ sh:path regen:landStewardStory ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:minLength 1 ;
sh:maxLength 500 ;
sh:datatype xsd:string
]
[
sh:path regen:landStewardStoryTitle ;
sh:resultMessage "regen:landStewardStoryTitle missing" ;
sh:minCount 1 ;
sh:maxCount 1 ;
sh:minLength 1 ;
sh:maxLength 160 ;
sh:datatype xsd:string
]
)
]
);
.
data.jsonld:
{
"@context": {
"regen": "http://regen.network/",
},
"@type": "regen:Project-Page",
"regen:landStewardStory": "In 1998, the local community supported
our plan to establish the Rukinga Wildlife Sanctuary that covers
80,000 acres of forest. We established a community works project so
local residents had an alternative income stream in place of poaching
and clear cutting. We brought on locally hired rangers and trained
them to be wilderness guardians. We convinced the owners of the
cattle to remove the cattle from the land to reduce conflict over
resources."
}
And here is the output from running "shacl validate --text
--shapes=schema.ttl --data=data.jsonld":
[ rdf:type sh:ValidationReport ;
sh:conforms false ;
sh:result [ rdf:type sh:ValidationResult ;
sh:focusNode _:b0 ;
sh:resultMessage "Or at focusNode
_:Bccda076ea2a1aedde6ef53f415f1b148" ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:OrConstraintComponent ;
sh:sourceShape regen:ProjectPageShape ;
sh:value _:b0
]
] .
The result I am looking for would look like this:
[ rdf:type sh:ValidationReport ;
sh:conforms false ;
sh:result [ rdf:type sh:ValidationResult ;
sh:focusNode _:b0 ;
sh:resultMessage "regen:landStewardStoryTitle
missing" ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:OrConstraintComponent ;
sh:sourceShape regen:ProjectPageShape ;
sh:value _:b0
]
] .
Any suggestions on how this could be achieved?
Thanks,
Kyle