w3c / shacl

SHACL Community Group (Post-REC activitities)
27 stars 4 forks source link

Need support for RDF datasets (i.e., graphs, quads) #22

Open TallTed opened 5 months ago

TallTed commented 5 months ago

Came up in https://github.com/w3c/vc-data-model/pull/1416#issuecomment-1915680267

afs commented 5 months ago

Some thoughts: https://afs.github.io/shacl-datasets.html

hmottestad commented 4 months ago

Here is what we came up with for RDF4J:

[
      a rsx:DataAndShapesGraphLink;
      rsx:shapesGraph <http://example.com/ns#shapesGraph1>;
      rsx:dataGraph ex:dataGraph, ex:dataGraph2;
]

There can be multiple shape graphs and multiple data graphs. The validator will union the shapes graph and parse those, the validate the shapes against the union of the data graphs.

A good thing about this approach is that users can split up their shapes into multiple graphs, then select some of those graphs to validate certain parts of the data. An example could be a ex:relaxedShapesGraph and a ex:strictShapesGraph where some data graphs will need to follow only the relaxed shapes while others need to follow both the strict and the relaxed shapes. A second example could be where there are common vocabularies in separate graphs ex:internalVocabularies and ex:commonVocabularies and we want to validate ex:shapesGraph1 together with the vocabulary graphs, but separate from ex:shapesGraph2.

In RDF4J users have to specify which named graphs can contain shapes. The ShaclSail will only parse shapes from those graphs. This allows users to validate untrusted data without having to worry that the data could contain shapes that would affect the validation. We also then require that any rsx:DataAndShapesGraphLink nodes be the shapes graphs. An rsx:DataAndShapesGraphLink needs to fully reside in a named graph, if it is split between two named graphs then we will ignore it.

https://github.com/eclipse-rdf4j/rdf4j/blob/2306c8b5b3f1d333e1259bb72ea1841b521c9deb/core/sail/shacl/src/test/resources/test-cases/minCount/unionDataset/shacl.trig#L19