TopQuadrant / shacl

SHACL API in Java based on Apache Jena
Apache License 2.0
214 stars 61 forks source link

Validation via CLI not working #102

Closed atextor closed 3 years ago

atextor commented 3 years ago

Hi, when I try to validate data using the shaclvalidate.sh CLI wrapper, it seems to never find any shapes violations but always returns a successful validation report.

To reproduce:

test-data.ttl:

@prefix ex: <http://example.com/ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:Alice
        a ex:Person ;
        ex:ssn "987-65-432A" .

ex:Bob
        a ex:Person ;
        ex:ssn "123-45-6789" ;
        ex:ssn "124-35-6789" .

ex:Calvin
        a ex:Person ;
        ex:birthDate "1971-07-07"^^xsd:date ;
        ex:worksFor ex:UntypedCompany .

test-shape.ttl:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/2001/XMLSchema#> .
@prefix ex: <http://example.com/ns#> .

ex:PersonShape
        a sh:NodeShape ;
        sh:targetClass ex:Person ;    # Applies to all persons
        sh:property [                 # _:b1
                sh:path ex:ssn ;           # constrains the values of ex:ssn
                sh:maxCount 1 ;
                sh:datatype xsd:string ;
                sh:pattern "^\\d{3}-\\d{2}-\\d{4}$" ;
        ] ;
        sh:property [                 # _:b2
                sh:path ex:worksFor ;
                sh:class ex:Company ;
                sh:nodeKind sh:IRI ;
        ] ;
        sh:closed true ;
        sh:ignoredProperties ( rdf:type ) .

Validating this should yield some results (e.g. duplicate ex:ssn), but running shaclvalidate.sh -datafile test-data.ttl -shapesfile test-shape.ttl yields

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

[ a       <http://www.w3.org/ns/shacl#ValidationReport> ;
  <http://www.w3.org/ns/shacl#conforms>
          true
] .
HolgerKnublauch commented 3 years ago

The line

@prefix sh: <http://www.w3.org/2001/XMLSchema#> .

does not look right. The namespace is http://www.w3.org/ns/shacl#

atextor commented 3 years ago

Oh no, how could I miss that. Thank you and sorry for the noise!