Open wouterbeek opened 9 months ago
I guess rdfs:subClassOf triples are what matters here. They impact sh:class and class-based targets.
I believe we could change SHACL Core so that these triples will be considered from the union of data and shapes graphs.
Would this address your concern or are there other triples in the data graph that should also be in the shapes graph and vice versa?
Can't we define that all rdfs:subClassOf
reasoning must happen in the shapes graph?
A union graph could make some edge cases, like validating constraints on a SHACL shape, difficult to process. A flag to enable that feature could solve it, but we should only consider it if there are other use cases than the rdfs:subClassOf
reasoning.
If we were to ignore rdfs:subClassOf triples from the data graph then we would introduce a breaking change to SHACL, which is something we definitely want to avoid for this (incremental) release. Adding the shapes graph as an extra graph to process is less likely to break existing use cases. But even that is potentially breaking.
An alternative solution is to introduce a new 3rd graph:
In SHACL 1.0 graph 3 is never given.
In SHACL 1.1, it becomes possible to optionally specify graph 3. If graph 3 is specified, then all class and property statements (RDFS/OWL, including rdfs:subClassOf
) are assumed to be in that graph. A user can choose to specify the same graph for (2) and (3).
Originally posed over at https://github.com/w3c/data-shapes/issues/155; also see the comments by others over there.
Observation
According to the SHACL standard, two graphs are relevant for validation: the data graph and the shapes graph. The ontology should be part of the data graph:
This seems counter-intuitive to me, since I associate the ontology more with the shapes graph. For example, a shapes graph can
owl:import
an ontology.Example
To illustrate my unease, let's take the following data graph:
And the following shapes graph:
Adding the following ontology graph is crucial, otherwise we cannot invalidate the data graph which is missing a
foaf:name
statement:Use case
I have a specific use case where this comes up: in TriplyETL we stream though the instance data. The stream passes along millions of small data graphs. For each of these data graphs, we have to add the ontology before the data graph can be validated in-stream. In this use case, it makes more sense to add the ontology to the shapes graph once, and use that same shapes graph to validate all data graphs that pass by.
Expected
I expect either of the following: