Chris,

Here's a shape that always executes and tests for an empty data graph.

# No violation
shacl validate -v -shapes ex-shapes.ttl -data not-empty.ttl

# Violation
shacl validate -v -shapes ex-shapes.ttl -data empty.nt

"sh:targetNode" always executes.

With this pattern, the SPARQL query can do arbitrary checks.

    Andy

## ex-shapes.ttl
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 xsd:     <http://www.w3.org/2001/XMLSchema#>

PREFIX ex:        <http://example/>

ex:NotEmptyGraphShape
  rdf:type sh:NodeShape ;
  sh:targetNode "Empty Graph" ;
  sh:sparql [
    a sh:SPARQLConstraint ;
    sh:select """
        SELECT $this ?value
        WHERE {
            FILTER NOT EXISTS { ?s ?p ?o }
        }
        """ ;
   ] .

On 11/05/2020 17:14, Chris Tomlinson wrote:

I appreciate that it works that way but until and unless I can understand your 
point about

  [] sh:targetNode ex:myNode

then I don’t know how to distinguish: 1) no violations because a Person graph 
conforms to the PersonShapes - like there’s no Work indicated as a parent of 
the person or a rdfs:label is used where a skos:prefLabel is expected; versus 
2) no violations because the question is vacuous like asking if a Work looks 
like a person or an empty non-existent graph looks like a person.

Reply via email to