Neo4j Shacl Help: targetClass has space

Hello, I'm trying to use shacl to validate the schema of my neo4j database and I have a node that has a label with a space in it. How do I specify the SHACL targetClass in this case?

So far I have...

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

CREATE (:`Soccer Player` {gender: 'male'})
CREATE (:`Soccer Player` {gender: 'female'})
CREATE (:`Soccer Player` {gender: 'NA'})

call n10s.validation.shacl.import.inline('
  @prefix neo4j: <neo4j://graph.schema#> .
  @prefix sh: <> .

  neo4j:SoccerPlayerShape a sh:NodeShape ;
    sh:targetClass neo4j:Soccer Player ;
    sh:property [
      sh:path neo4j:gender ;
      sh:datatype xsd:string ;
      sh:in ("female" "male");
', 'Turtle')

Hi @john.dzak nice catch.
White spaces are in general not great in URIs that can make some RDF parsers choke.
In the n10s.*.import.* methods you have the option to accept any kind of syntax in a URI by setting the verifyUriSyntax param to false.
This option was not available for the n10s.validation.shacl.import.* methods so the quick answer is that with the current version of n10s you cannot do it.
Now the good news is that it was a relatively simple fix to add support for it and the changes are in now, which means that you can either build from source today or if you prefer, you can wait till next release that should be out in just a couple of weeks. Here's the syntax you will need to use:

CALL n10s.validation.shacl.import.inline('...path to your file...','Turtle', { verifyUriSyntax: false })

Hope this helps.

PS: Introducing 'irregular' URIs is straightforward with other serialisation formats like RDF/XML or N-Triples where URIs are clearly delimited. WIth Turtle you'll have to trick the parser. Check out the hack I used in the unit test for this case.


Thanks for the quick reply and fix @jesus_barrasa!

I'm curious to try out other serialisation formats like RDF/XML or N-Triples like you mentioned. Do you have any examples that I can use to validate my schema using those formats?

Thanks again, John

There should be some examples of RDF in different serialisations in the manual but I'd recommend this service to convert from one to another.



1 Like