On 28/01/2022 12:27, Alani, Yasir wrote:
Hi Andy,
Have you had a chance to look at the difference between the overloaded "validate" methods
of "ShaclValidator", in terms of qualified value shapes.
See message of 2021-01-27.
Jena gets one validation error - this is correct. If you call it with
one target node, you only get the validation errors for that target node.
That's what the command line is doing as well.
shacl v -data data.ttl -shapes shapes.ttl \
-target 'http://www.semanticweb.org/yas#Car_1'
NB: You need to call it with "http://www.semanticweb.org/yas#Car_1"
not "yas:Car_1".
public static void main(String... args) throws IOException {
String DIR = ....
Graph data = RDFDataMgr.loadGraph(DIR+"/data.ttl");
Graph shapes = RDFDataMgr.loadGraph(DIR+"/shapes.ttl");
Node target = NodeFactory.createURI
("http://www.semanticweb.org/yas#Car_1");
ValidationReport report = ShaclValidator.get()
.validate(shapes, data, target);
RDFDataMgr.write(System.out, report.getGraph(), Lang.TTL);
}
Andy
Apologies if I bothered you with this.
Yasir
-----Original Message-----
From: Andy Seaborne <a...@apache.org>
Sent: 27 January 2022 08:40
To: users@jena.apache.org
Subject: Re: FW: Validation issue
On 26/01/2022 22:49, Alani, Yasir wrote:
*The node to be validated is "yas:Car_1"
Thanks again
-----Original Message-----
From: Alani, Yasir <y.al...@tees.ac.uk>
Sent: 26 January 2022 22:38
To: users@jena.apache.org
Subject: RE: FW: Validation issue
Hi Andy,
Thank you for responding.
What I meant by "work" is producing the correct/expected result, which is the 2 violations you
received. The issue only seems to happen when I try to validate a node using the method "validate(Shapes
shapes, Graph data, Node node)". The node in this case is "aso:Car_1". This method doesn't
seem to 'like' qualified value shapes, as it returns 0 violations.
I get one violation when calling:
shacl v -data data.ttl -shapes shapes.ttl \
-target
'https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.semanticweb.org%2Fyas%23Wheel_1&data=04%7C01%7CY.Alani%40tees.ac.uk%7Ce6691c8465804ae8f02708d9e170a7e8%7C43d2115ba55e46b69df7b03388ecfc60%7C0%7C0%7C637788696243499932%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=TY3YRMvJpeBcPAMkQKbtRMIUCAK%2BOE24Cr%2BPezQ9Ziw%3D&reserved=0'
There are two target nodes. yas:Wheel_1 and yas:Car_1
"Per node" is "find which shapes have the node as a target node and call that
shape".
If the specified node isn't in the targets of the data+shapes, you get zero
violations.
Andy
However, when I validate the entire data graph using method "validate(Shapes shapes,
Graph data)" I do get 2 violations. Are these methods designed to work this way?
I was using Jena 4.1.0 and even when I updated to Jena 4.3.2, I still get the
same results.
I used the old (TQ) shacl playground, which returned 2 violations as well.
Many thanks
Yasir
-----Original Message-----
From: Andy Seaborne <a...@apache.org>
Sent: 26 January 2022 20:41
To: users@jena.apache.org
Subject: Re: FW: Validation issue
Yasir,
What is "work" here?
I get 2 violations with Jena 4.3.2 - the same as (current latest) TQ
shacl. (1 violation on a quite old, pre 4.x.x version of Jena - which
version are you running?)
Which SHACL playground did you use (there are two).
The old (TopQuadrant) SHACL playground returns 2 violations.
The Zazuko one returns 2 violations.
[ rdf:type sh:ValidationReport ;
sh:conforms false ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode yas:Wheel_1 ;
sh:resultMessage
"Data value \"600\"^^xsd:float is not less than or equal to 200" ;
sh:resultPath ( yas:hasDiameter yas:hasValue ) ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MaxInclusiveConstraintComponent ;
sh:sourceShape [] ;
sh:value "600"^^xsd:float
] ;
sh:result [
rdf:type sh:ValidationResult ;
sh:focusNode yas:Car_1 ;
sh:resultMessage
"QualifiedValueShape[1,_,false]: Min = 1 but got 0 validations" ;
sh:resultPath yas:hasComponent ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent
sh:QualifiedMinCountConstraintComponent ;
sh:sourceShape []
]
] .
Andy