fun with sh:hasShape

What happens here?  Why?  Is what happens reasonable?


Data graph

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix sh:  <http://www.w3.org/ns/shacl#> .
@prefix ex:  <http://example.org/ex/> .
@prefix s:   <http://example.org/s/> .

ex:foo1 rdf:type ex:foo ;
 rdf:type ex:bar ;
  s:shape s:bar .

ex:foo2 rdf:type ex:foo ;
 rdf:type ex:baz ;
  s:shape s:bar .

ex:foo3 rdf:type ex:foo ;
 rdf:type ex:baz ;
  s:shape s:baz .

ex:foo4 rdf:type ex:foo ;
 rdf:type ex:baz ;
  s:shape s:s0 .

ex:foo5 rdf:type ex:foo ;
 rdf:type ex:baz ;
  s:shape s:s1 .

ex:foon1 rdf:type ex:foon ;
 rdf:type ex:baz ;
  s:shape s:s2 .



Shapes graph

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix sh:  <http://www.w3.org/ns/shacl#> .
@prefix ex:  <http://example.org/ex/> .
@prefix s:   <http://example.org/s/> .

s:s1 rdf:type sh:Shape ;
  sh:targetClass ex:foo ;
  sh:sparql [
    sh:select
      """SELECT $this WHERE {
        $this s:shape ?shape ;
 BIND (sh:hasShape($this,?shape,$shapesGraph) AS ?hasShape)
        BIND (!bound(?hasShape) AS ?failure )
        FILTER (?failure || !?hasShape) }""" ] .

s:bar sh:class ex:bar .

s:baz sh:class ex:baz .

s:s2 rdf:type sh:Shape ;
  sh:targetClass ex:foon ;
  sh:sparql [
    sh:select
      """SELECT $this WHERE {
        $this s:shape ?shape ;
 BIND (sh:hasShape($this,?shape,$shapesGraph) AS ?hasShape)
        BIND (!bound(?hasShape) AS ?failure )
        FILTER (?failure || ?hasShape) }""" ] .


Peter F. Patel-Schneider
Nuance Communications

Received on Monday, 26 September 2016 19:02:23 UTC