W3C home > Mailing lists > Public > public-rdf-shapes@w3.org > September 2016

fun with sh:hasShape

From: Peter F. Patel-Schneider <pfpschneider@gmail.com>
Date: Mon, 26 Sep 2016 12:01:49 -0700
To: "public-rdf-shapes@w3.org" <public-rdf-shapes@w3.org>
Message-ID: <5ab45f41-1739-5ea1-7e07-672f6c0bbbe5@gmail.com>
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

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:02:44 UTC