zazuko / rdf-validate-shacl

Validate RDF data purely in JavaScript. An implementation of the W3C SHACL specification on top of the RDFJS stack.
MIT License
98 stars 13 forks source link

Lift syntactic restrictions on property path notation #69

Closed wouterbeek closed 2 years ago

wouterbeek commented 3 years ago

User story

Background

SHACL 1.0 puts syntactic restrictions on how complex property paths should be encoded. It is strange that such syntactic restrictions are mandated, since RDF lists may consist of blank nodes or IRIs or combinations of blank nodes and IRIs in any other context. In contexts where blank nodes are Skolemized to well-known IRI (a common practice that is part of the RDF 1.1 standard) complex property paths cannot be used at all.

A more in-depth discussion is over at https://github.com/w3c/data-shapes/issues/137.

Would it be possible to lift this restriction on syntax in this library? Maybe using an option to indicate that this functionality purposefully deviates from the SHACL 1.0 standard in this respect.

Example

The following snippet gives a full example. The complex property path is encoded using IRI i.o. blank nodes. If the list IRI (<list-pq>) is replaced with the Turtle list notation (<p><q>) then the snippet works as intended.

prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix sh: <http://www.w3.org/ns/shacl#>
<shp>
  sh:property <pq-shp>;
  sh:targetSubjectsOf <p>.
<pq-shp>
  sh:class <C>;
  sh:minCount 1;
  sh:path <list-pq>.
<list-pq>
  a rdf:List;
  rdf:first <p>;
  rdf:rest <list-q>.
<list-q>
  a rdf:List;
  rdf:first <q>;
  rdf:rest rdf:nil.
<a> <p> <b>.
<b> <q> <c>.
<c> a <C>.