title: What is the difference between these shape graphs which use sh:or?
body: <p>I have the following Data Graph.</p>
  
  <pre><code>@prefix hr: &lt;http://learningsparql.com/ns/humanResources#&gt; .
  @prefix rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
  @prefix rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt; .
  @prefix sch: &lt;http://schema.org/&gt; .
  @prefix xml: &lt;http://www.w3.org/XML/1998/namespace&gt; .
  @prefix xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt; .
  
  hr:Another a rdfs:Class .
  
  hr:Employee a rdfs:Class ;
      rdfs:label "model" ;
      rdfs:comment "a good employee" .
  
  hr:Longer a hr:Employee ;
      rdfs:label "model" ;
      rdfs:comment "a good employee" .
  
  hr:freestanding a rdf:Property ;
      sch:rangeIncludes sch:Text .
  
  hr:missing rdfs:comment "some comment about missing" .
  
  hr:name a rdf:Property ;
      sch:domainIncludes hr:Employee .
  
  hr:nosuper a rdf:Property ;
      sch:domainIncludes hr:Uncreated ;
      sch:rangeIncludes sch:Text .
  
  hr:randomtype a hr:invalidtype ;
      rdfs:label "some label about randomtype" ;
      rdfs:comment "some comment about randomtype" .
  
  hr:typo a rdfs:Classs ;
      rdfs:label "some label about typo" ;
      rdfs:comment "some comment about typo" .
  </code></pre>
  
  <p>I am trying to understand the difference between these two Shape Graphs, which I think (wrongly!) should return the same result...validation errors for hr:typo, hr:randomtype, and hr:missing because there is no rdf:type property path to either rdfs:Class or rdf:Property.</p>
  
  <p>The following Shape Graph produces the expected validation errors.</p>
  
  <p>(A) -- good results</p>
  
  <pre><code>            @prefix rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt; .
              @prefix rdf:  &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
              @prefix sch:  &lt;http://schema.org/&gt; .
              @prefix sh:   &lt;http://www.w3.org/ns/shacl#&gt; .
              @prefix ex:   &lt;http://example.org/&gt; .
  
              ex:ClassShape
                  a sh:NodeShape ;
  
                  sh:property [
                      sh:path [ sh:zeroOrMorePath rdf:type ];
                      sh:nodeKind sh:IRI ;
                      sh:hasValue rdfs:Class;
                      sh:message "class" ;
                  ] .
  
              ex:PropertyShape
                  a sh:NodeShape ;
  
                  sh:property [
                      sh:path [ sh:zeroOrMorePath rdf:type ];
                      sh:nodeKind sh:IRI ;
                      sh:hasValue rdf:Property;
                      sh:message "property" ;
                  ] .
  
              ex:ClassOrProperty
                  a sh:NodeShape ;
                  sh:target [
                      a sh:SPARQLTarget ;
                      sh:select   """
                                  SELECT ?this
                                  WHERE {
                                      ?this ?p ?o .
                                  }
                                  """ ;
                  ] ;
  
                  sh:or (
                      ex:ClassShape
                      ex:PropertyShape
                  );
              .            
  </code></pre>
  
  <p>The good and expected validation errors produced by (A) are:</p>
  
  <pre><code>Validation Report
  Conforms: False
  Results (3):
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: ex:ClassOrProperty
      Focus Node: hr:randomtype
      Value Node: hr:randomtype
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: ex:ClassOrProperty
      Focus Node: hr:typo
      Value Node: hr:typo
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: ex:ClassOrProperty
      Focus Node: hr:missing
      Value Node: hr:missing
  </code></pre>
  
  <p>However, this Shape Graph:</p>
  
  <p>(B) -- bad results</p>
  
  <pre><code>                    @prefix rdfs: &lt;http://www.w3.org/2000/01/rdf-schema#&gt; .
                      @prefix rdf:  &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .
                      @prefix sch:  &lt;http://schema.org/&gt; .
                      @prefix sh:   &lt;http://www.w3.org/ns/shacl#&gt; .
                      @prefix ex:  &lt;http://example.org/&gt; .
  
                      ex:ClassOrProperty
                          a sh:NodeShape ;
                          sh:target [
                              a sh:SPARQLTarget ;
                              sh:select   """
                                          SELECT ?this
                                          WHERE {
                                              ?this ?p ?o .
                                          }
                                          """ ;
                          ] ;
  
                          sh:property [
                              sh:path     [sh:zeroOrMorePath rdf:type] ;
                              sh:nodeKind sh:IRI ;
                              sh:or (
                                  [ sh:hasValue rdfs:Class;   ]
                                  [ sh:hasValue rdf:Property; ]
                              )
                          ];
                      .
  </code></pre>
  
  <p>does not produce only the expected validation errors. I get:</p>
  
  <pre><code>Validation Report
  Conforms: False
  Results (12):
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: [ sh:nodeKind sh:IRI ; sh:or ( [ sh:hasValue rdfs:Class ] [ sh:hasValue rdf:Property ] ) ; sh:path [ sh:zeroOrMorePath rdf:type ] ]
      Focus Node: hr:freestanding
      Value Node: hr:freestanding
      Result Path: [ sh:zeroOrMorePath rdf:type ]
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: [ sh:nodeKind sh:IRI ; sh:or ( [ sh:hasValue rdfs:Class ] [ sh:hasValue rdf:Property ] ) ; sh:path [ sh:zeroOrMorePath rdf:type ] ]
      Focus Node: hr:name
      Value Node: hr:name
      Result Path: [ sh:zeroOrMorePath rdf:type ]
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: [ sh:nodeKind sh:IRI ; sh:or ( [ sh:hasValue rdfs:Class ] [ sh:hasValue rdf:Property ] ) ; sh:path [ sh:zeroOrMorePath rdf:type ] ]
      Focus Node: hr:Another
      Value Node: hr:Another
      Result Path: [ sh:zeroOrMorePath rdf:type ]
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: [ sh:nodeKind sh:IRI ; sh:or ( [ sh:hasValue rdfs:Class ] [ sh:hasValue rdf:Property ] ) ; sh:path [ sh:zeroOrMorePath rdf:type ] ]
      Focus Node: hr:nosuper
      Value Node: hr:nosuper
      Result Path: [ sh:zeroOrMorePath rdf:type ]
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: [ sh:nodeKind sh:IRI ; sh:or ( [ sh:hasValue rdfs:Class ] [ sh:hasValue rdf:Property ] ) ; sh:path [ sh:zeroOrMorePath rdf:type ] ]
      Focus Node: hr:Employee
      Value Node: hr:Employee
      Result Path: [ sh:zeroOrMorePath rdf:type ]
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: [ sh:nodeKind sh:IRI ; sh:or ( [ sh:hasValue rdfs:Class ] [ sh:hasValue rdf:Property ] ) ; sh:path [ sh:zeroOrMorePath rdf:type ] ]
      Focus Node: hr:randomtype
      Value Node: hr:randomtype
      Result Path: [ sh:zeroOrMorePath rdf:type ]
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: [ sh:nodeKind sh:IRI ; sh:or ( [ sh:hasValue rdfs:Class ] [ sh:hasValue rdf:Property ] ) ; sh:path [ sh:zeroOrMorePath rdf:type ] ]
      Focus Node: hr:randomtype
      Value Node: hr:invalidtype
      Result Path: [ sh:zeroOrMorePath rdf:type ]
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: [ sh:nodeKind sh:IRI ; sh:or ( [ sh:hasValue rdfs:Class ] [ sh:hasValue rdf:Property ] ) ; sh:path [ sh:zeroOrMorePath rdf:type ] ]
      Focus Node: hr:typo
      Value Node: hr:typo
      Result Path: [ sh:zeroOrMorePath rdf:type ]
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: [ sh:nodeKind sh:IRI ; sh:or ( [ sh:hasValue rdfs:Class ] [ sh:hasValue rdf:Property ] ) ; sh:path [ sh:zeroOrMorePath rdf:type ] ]
      Focus Node: hr:typo
      Value Node: rdfs:Classs
      Result Path: [ sh:zeroOrMorePath rdf:type ]
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: [ sh:nodeKind sh:IRI ; sh:or ( [ sh:hasValue rdfs:Class ] [ sh:hasValue rdf:Property ] ) ; sh:path [ sh:zeroOrMorePath rdf:type ] ]
      Focus Node: hr:missing
      Value Node: hr:missing
      Result Path: [ sh:zeroOrMorePath rdf:type ]
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: [ sh:nodeKind sh:IRI ; sh:or ( [ sh:hasValue rdfs:Class ] [ sh:hasValue rdf:Property ] ) ; sh:path [ sh:zeroOrMorePath rdf:type ] ]
      Focus Node: hr:Longer
      Value Node: hr:Employee
      Result Path: [ sh:zeroOrMorePath rdf:type ]
  Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
      Severity: sh:Violation
      Source Shape: [ sh:nodeKind sh:IRI ; sh:or ( [ sh:hasValue rdfs:Class ] [ sh:hasValue rdf:Property ] ) ; sh:path [ sh:zeroOrMorePath rdf:type ] ]
      Focus Node: hr:Longer
      Value Node: hr:Longer
      Result Path: [ sh:zeroOrMorePath rdf:type ]
  </code></pre>
  
  <p>Why are the results different? </p>
  
  <p>The reason why I liked (B) over (A) is because it would have been more concise, if it had worked.</p>
  
  <p>Both <a href="https://github.com/RDFLib/pySHACL" rel="nofollow noreferrer">pySHACL</a> and <a href="https://github.com/TopQuadrant/shacl" rel="nofollow noreferrer">TopBraid SHACL API shaclvalidate.sh</a> agree on the results.</p>