[
https://issues.apache.org/jira/browse/JENA-1979?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17211717#comment-17211717
]
Andy Seaborne commented on JENA-1979:
-------------------------------------
Thanks for the report.
The {{$PATH}} feature on complex paths in the SHACL spec makes some assumptions
about how a SPARQL query is executed (it assumes it is parsed on every
constraint invocation). The spec states "substitute" for {{$PATH}} but you
can't substitute a binding for anything other than a property. That is somewhat
of a burden.
Jena will protect against the situation of un-substitutable path. Whether it
will full implement the full inefficient form is another matter.
----
While in the area, I checked DASH. If you are using material from that, you may
need to modify it.
Despite the comment text that it is nearly standard compliant, it isn't any
longer.
# It imports TOSH which is specific to TopQuadrant products.
# There are now quite few constraints only defined for JavaScript validation
with no standard's compliant alternative.
> SHACL validation: NullPointerException when shapes with sh:alternativePath
> importing <http://datashapes.org/dash>
> -----------------------------------------------------------------------------------------------------------------
>
> Key: JENA-1979
> URL: https://issues.apache.org/jira/browse/JENA-1979
> Project: Apache Jena
> Issue Type: Bug
> Components: SHACL
> Affects Versions: Jena 3.16.0
> Environment: Run
> {{Graph shapesGraph =
> ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM).read("shapes.ttl",
> "TTL").getGraph();}}
> {{ Graph dataGraph =
> ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM).read("data.ttl",
> "TTL").getGraph();}}
> {{ validator = ShaclValidator.get();}}
> {{ return validator.validate(shapesGraph, dataGraph);}}
> Reporter: Jan Rosecky
> Priority: Major
> Attachments: data.ttl, shapes.ttl
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> h2. How to replicate
> Run
> {{{{Graph shapesGraph =
> ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM).read("shapes.ttl",
> "TTL").getGraph();}}}}
> {{Graph dataGraph =
> ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM).read("data.ttl",
> "TTL").getGraph();}}}}
> {{validator = ShaclValidator.get();}}
> {{return validator.validate(shapesGraph, dataGraph);}}
> Files attached.
> h2. What is happening
> The exception happens when a property shape with sh:alternativePath is
> evaluated inside ConstraintComponentSPARQL. I'm not sure why however it only
> happens when dash/tosh shapes are imported by a shape.
> The exception seems to happen on line 239 of SparqlValidation.java:
> {{RDFNode z = ModelUtils.convertGraphNodeToRDFNode(ShaclPaths.pathNode(path),
> model);}}
> where pathNode() returns null - only supporting P_Link, not P_Alt and
> convertGraphNodeToRDFNode() then runs unchecked node.isVariable().
> Stack trace:
> {{parameterMapToPreBinding:239, SparqlValidation
> (org.apache.jena.shacl.engine.constraint)}}
> {{validateMap:122, SparqlValidation
> (org.apache.jena.shacl.engine.constraint)}}
> {{validate:87, SparqlValidation (org.apache.jena.shacl.engine.constraint)}}
> {{lambda$validatePropertyShape$0:69, ConstraintComponentSPARQL
> (org.apache.jena.shacl.engine.constraint)}}
> {{accept:-1, 1035363280
> (org.apache.jena.shacl.engine.constraint.ConstraintComponentSPARQL$$Lambda$125)}}
> {{forEach:75, Iterable (java.lang)}}
> {{validatePropertyShape:68, ConstraintComponentSPARQL
> (org.apache.jena.shacl.engine.constraint)}}
> {{evalConstraint:264, ValidationProc (org.apache.jena.shacl.validation)}}
> {{validationPropertyShape:248, ValidationProc
> (org.apache.jena.shacl.validation)}}
> {{validationPropertyShapes:228, ValidationProc
> (org.apache.jena.shacl.validation)}}
> {{validateShape:219, ValidationProc (org.apache.jena.shacl.validation)}}
> {{simpleValidationInternal:178, ValidationProc
> (org.apache.jena.shacl.validation)}}
> {{simpleValidation:122, ValidationProc (org.apache.jena.shacl.validation)}}
> {{simpleValidation:109, ValidationProc (org.apache.jena.shacl.validation)}}
> {{simpleValidation:101, ValidationProc (org.apache.jena.shacl.validation)}}
> {{validate:79, ShaclSimpleValidator (org.apache.jena.shacl.validation)}}
> {{validate:91, ShaclSimpleValidator (org.apache.jena.shacl.validation)}}
> {{validate:23, mytest (com.msd.gin.mrlitdi.test)}}
> {{run:17, mytest (com.msd.gin.mrlitdi.test)}}
> {{invoke0:-1, NativeMethodAccessorImpl (sun.reflect)}}
> {{invoke:62, NativeMethodAccessorImpl (sun.reflect)}}
> {{invoke:43, DelegatingMethodAccessorImpl (sun.reflect)}}
> {{invoke:498, Method (java.lang.reflect)}}
> {{runReflectiveCall:50, FrameworkMethod$1 (org.junit.runners.model)}}
> {{run:12, ReflectiveCallable (org.junit.internal.runners.model)}}
> {{invokeExplosively:47, FrameworkMethod (org.junit.runners.model)}}
> {{evaluate:17, InvokeMethod (org.junit.internal.runners.statements)}}
> {{runLeaf:325, ParentRunner (org.junit.runners)}}
> {{runChild:78, BlockJUnit4ClassRunner (org.junit.runners)}}
> {{runChild:57, BlockJUnit4ClassRunner (org.junit.runners)}}
> {{run:290, ParentRunner$3 (org.junit.runners)}}
> {{schedule:71, ParentRunner$1 (org.junit.runners)}}
> {{runChildren:288, ParentRunner (org.junit.runners)}}
> {{access$000:58, ParentRunner (org.junit.runners)}}
> {{evaluate:268, ParentRunner$2 (org.junit.runners)}}
> {{run:363, ParentRunner (org.junit.runners)}}
> {{run:137, JUnitCore (org.junit.runner)}}
> {{startRunnerWithArgs:69, JUnit4IdeaTestRunner (com.intellij.junit4)}}
> {{startRunnerWithArgs:33, IdeaTestRunner$Repeater (com.intellij.rt.junit)}}
> {{prepareStreamsAndStart:220, JUnitStarter (com.intellij.rt.junit)}}
> {{main:53, JUnitStarter (com.intellij.rt.junit)}}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)