sparna-git / shacl-play

SHACL validation UI, SHACL documentation generator, SHACL generator from RDF.
http://shacl-play.sparna.fr
GNU Lesser General Public License v3.0
24 stars 15 forks source link

sh:or does not work if properties are in blank nodes #79

Closed agustaf9 closed 1 year ago

agustaf9 commented 1 year ago

Using https://shacl-play.sparna.fr/play/draw

The following ttl will give an error:

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix ex: <https://example.com/ontologies/ex#> .

ex:Shape1
    a owl:Class ;
    a sh:NodeShape ;
    rdfs:label "Shape 1" ;
    sh:property [
        sh:path ex:ReportsTo ;
        sh:name "Shape1 Property1" ;
        sh:nodeKind sh:IRI ;
        sh:or (
                    [
                        sh:class ex:Shape1 ;
                    ]
                    [
                        sh:class ex:Shape2 ;
                    ]
                ) ;
    ] ;
.
ex:Shape2
    a owl:Class ;
    a sh:NodeShape ;
    rdfs:label "Shape2" ;
.

While this ttl will correctly generate the diagram:

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix ex: <https://example.com/ontologies/ex#> .

ex:Shape1
    a owl:Class ;
    a sh:NodeShape ;
    rdfs:label "Shape 1" ;
    sh:property ex:Shape1-Property1
.
ex:Shape1-Property1
    sh:path ex:ReportsTo ;
    sh:name "Shape1 Property1" ;
    sh:nodeKind sh:IRI ;
    sh:or (
        [
            sh:class ex:Shape1 ;
        ]
        [
            sh:class ex:Shape2 ;
        ]
    ) ;
.
ex:Shape2
    a owl:Class ;
    a sh:NodeShape ;
    rdfs:label "Shape2" ;
.

The only difference is that the property shape is not in a blank node in the second example.

The error given is: Error java.lang.NullPointerException : null

Locally I am running one release behind the hosted version and I get a more descriptive error: Error java.lang.NullPointerException : Cannot invoke "String.replace(java.lang.CharSequence, java.lang.CharSequence)" because the return value of "org.apache.jena.rdf.model.Resource.getLocalName()" is null