You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Kyle Lawlor-Bagcal <ky...@regen.network.INVALID> on 2023/01/11 22:02:05 UTC
Increasing verbosity of shacl cli tool to show sh:message or sh:resultMessage
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
Re: Increasing verbosity of shacl cli tool to show sh:message or sh:resultMessage
Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
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
>
Re: Increasing verbosity of shacl cli tool to show sh:message or sh:resultMessage
Posted by Andy Seaborne <an...@apache.org>.
On 11/01/2023 22: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/",
Syntax error in the JSON.
>> },
>> "@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?
The constraint failing is the sh:or which doesn't have a resultMessage.
Rereading the SHACL spec, there isn't any text about rolling up messages
- what do other engines do?
There is the Zazuko SAHCL playground
https://shacl-playground.zazuko.com/
it find s the violation but it does not print a message.
Some of the SHACL user community are to be found on Discord:
https://discord.gg/RTbGfJqdKB
where you might get suggestions.
via
https://lists.w3.org/Archives/Public/public-shacl/2021Nov/0007.html
Andy
>
> Thanks,
> Kyle
>