Importing SHACL for graph validation (namespaces..?)


I want to use neosemantics to validate a graph in neo4j, but I'm having trouble to get the model constraints loaded on a minimal example:

Suppose I have the following graph:

CREATE (n:Person {name: 'Andy'})

Then, I initialize neosemantics as follows:

CALL n10s.graphconfig.init();

Now I should be good to go and validate the graph. Based on what I found here (Validating Neo4j graphs against SHACL - Neosemantics), I thought that the following schema should work as a first approach:

call n10s.validation.shacl.import.inline('

@prefix neo4j: <> .
@prefix sh: <> .

neo4j:PersonShape a sh:NodeShape ;
  sh:targetClass neo4j:Person ;
  sh:property [
    sh:path neo4j:name ;
    sh:datatype xsd:string ;

However, that gives me:

Failed to invoke procedure `n10s.validation.shacl.import.inline`: Caused by: n10s.utils.UriUtils$UriNamespaceHasNoAssociatedPrefix: Prefix Undefined: No prefix defined for namespace <>. Use n10s.nsprefixes.add(...) procedure.

It felt weird, but to match that error message, I tried adding the line

@prefix neo4jPerson: <> .

but that didn't help.

I then tried the following:

CALL n10s.graphconfig.init({handleVocabUris:"IGNORE"});

Then, the validation rule is accepted, but it doesn't really look connected to anything:

target  propertyOrRelationshipPath  param   value
"__NONE__"  "__NONE__"  "datatype"  "string"

I thought that it would be helpful to remove that namespace stuff all along. So I also tried

call n10s.validation.shacl.import.inline('

@prefix neo4j: <> .
@prefix sh: <> .

PersonShape a sh:NodeShape ;
  sh:targetClass Person ;
  sh:property [
    sh:path name ;
    sh:datatype xsd:string ;

But that didn't work either as the parser insists on getting that namespace stuff to work:

Failed to invoke procedure `n10s.validation.shacl.import.inline`: Caused by: Expected ':', found ' ' [line 6]

I'm a bit at a loss here. The code I've given is more or less taken from the neosemantics user guide (Neosemantics(n10s) User Guide - Neosemantics) and only adapted slightly.

I should add that I can import the original schema just fine with handleVocabUris: KEEP.

But still something isn't linked correctly. I added a shape that definitely violates the specification (name is missing):

CREATE (n:Person {violation: 5})

Then I ran the validation with

call n10s.validation.shacl.validate() yield focusNode, nodeType,propertyShape,offendingValue,resultPath,severity

but the result remained empty.
What am I missing?

I solved it: cypher - neo4j neosemantics: loading model constraints - Stack Overflow