shacl property shape without sh:targetClass not validating

44 views Asked by At

I want to define a SHACL PropertyShape to validate the object data type of a predicate without specifying a target class.

Here is an excerpt of the test ontology:

ex:Journey a owl:class .
ex:Stay a owl:Class .

ex:hasStartDate rdf:type owl:DatatypeProperty ;
        rdfs:label "Start Datum"@de ,
                   "Start date"@en ;
        rdfs:comment "The start of an activity."@en .

I define the following PropertyShape to validate that the object of the ex:hasStartDate property is always of type xsd:date:

ex:startDateShape a sh:PropertyShape ;
    sh:path ex:hasStartDate;
    sh:datatype xsd:date .

This SHACL validation completely ignores this shape and the following data that should result in two violations is then valid:


ex:excursion1 a ex:Journey ;
              ex:hasStartDate "1987" .

ex:stay1 a ex:Stay ;
         ex:hasStartDate "1987" .

I don't want to add any sh:targetClass to my PropertyShape because I want this PropertyShape to be enforced independently on nodes of any type and irrespective of the subject of the triple. The reason behind this is that I want this property to be also validated when used with an RDF-star statement, as shown below: The following data should be valid:

<< ex:Bob ex:traveledTo dbr:London >> ex:hasStartDate "2023-02-10"^^xsd:date .

The following data should be invalid:

<< ex:Bob ex:traveledTo dbr:London >> ex:hasStartDate "2023-02-10" .

I would appreciate any hint.

0

There are 0 answers