On 08/05/2020 21:34, Chris Tomlinson wrote:
Hello,
I’ve enabled a shacl endpoint as described in Apache Jena Shacl
<https://jena.apache.org/documentation/shacl/> and have some questions.
Our objective in using the endpoint is to be able to validate a given resource
graph in the tdb:unionDefaultGraph against a given shapes graph.
1) I added:
fuseki:endpoint [ fuseki:operation fuseki:shacl ; fuseki:name "shacl" ] ;
to the Fuseki assembler file for a dataset and restarted, and it is reachable.
One observation is that using the above “new style” endpoint declaration
apparently can be replaced by:
fuseki:serviceShacl "shacl" ;
I’m not sure about this but the comment in the doc:
This is not installed into a dataset setup by default; a configuration file
using fuseki:serviceShacl is necessary
seems to suggest it sort of.
That wasn't intended - I'll fix the documentation.
The limitation is that fuseki:serviceQuery etc require fixed names to
known to the configuration engine which is in fuseki-core.
Extension operations (new operations can be added to Fuseki) use the new
style where the predicate is fuseki:operation. In fact, for SHACL, it
can be added quite simply because it comes from Jena itself but the code
seems to say that the old-style isn't enabled.
2) In any event, when I call the endpoint like:
curl -s GET http://ldspdi-dev.bdrc.io/shapes/core/PersonShapes | curl -XPOST
--data-binary @- --header 'Content-type: text/turtle'
'http://ahost:aport/fuseki/newcorerw/shacl?http://purl.bdrc.io/graph/P707'
Maybe it's email corruption but that isn't the invocation syntax.
That should have ?graph=
Otherwise it defaults to "?graph=default" which seems consistent with
the report.
"?http://purl.bdrc.io/graph/P707" is going to be ignored and for you
that's the union default graph.
I see a result like:
[ a sh:ValidationReport ;
sh:conforms false ;
sh:result [ a sh:ValidationResult ;
sh:focusNode bdr:UNKNOWN_Person ;
sh:resultMessage "minCount[1]: Invalid cardinality:
expected min 1: Got count = 0" ;
sh:resultPath bdo:personName ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MinCountConstraintComponent ;
sh:sourceShape bds:PersonShape-personName
]
] .
which is surprising given that there’s no reference in the graph
http://purl.bdrc.io/graph/P707 <http://purl.bdrc.io/graph/P707> that refers
eventually to bdr:UNKNOWN_Person. The P707 graph is a Person graph. I’ve also tried
using an encoded url, http%3a%2f%2fpurl.bdrc.io%2fgraph%2fP707, but that makes no
difference.
In fact, using a non-Person graph like http://purl.bdrc.io/graph/W12827
<http://purl.bdrc.io/graph/W12827> produces the same result. As does, submitting a
non-existent graph URL like http://no.such.org/flip/flop
<http://no.such.org/flip/flop>.
See above.
This all leads me to conclude that SHACL-Validation#L61
<https://github.com/apache/jena/blob/ab7882a73445c7a75e811eb58d06211c410891b0/jena-fuseki2/jena-fuseki-core/src/main/java/org/apache/jena/fuseki/servlets/SHACL_Validation.java#L61>
isn’t getting in a way that I understand.
I haven’t found any logging that gives any helpful entries and so I’m asking
questions rather than diving deeper for now.
If I use another shape graph like http://ldspdi-dev.bdrc.io/shapes/core/WorkShapes
<http://ldspdi-dev.bdrc.io/shapes/core/WorkShapes>, then I get a result like:
[ a sh:ValidationReport ;
sh:conforms true
] .
again regardless of the graph argument.
I don’t understand the results.
3) This result leads to a related question. It seems that a result of:
sh:conforms true
means that the data graph conforms to the shapes graph in all respects where
the shapes graph picks out features in the data graph, even if the shapes graph
picks out nothing at all in the data graph.
Yes - that a SHACL-ism.
An empty graph or graph with no targets is "conforms true".
Is there any way to tell whether the shapes graph in some sense doesn’t apply
to the data graph? This seems like an important distinction.
You can add a constraint that is always triggered.
[] sh:targetNode ex:myNode
is always triggered; it does not require ex:myNode to be in the data.
From there, a SPARQL constraint could do any validations for "right
graph", "empty graph" etc.
I appreciate any help on these questions,
Chris
Andy