Search code examples
validationgraphrdfowlshacl

How should sh:shapesGraph be interpreted in comparison to owl:import?


I am struggling to comprehend how sh:shapesGraph should be used. So far I've used a SHACL validator that does traverse the owl:import and brings content to the data graph so that I can benefit from rdfs:subClassOf etc.

But, according to the SHACL specification, sh:shapesGraph declaration in the data graph "is an IRI representing a graph that should be included into the shapes graph used to validate the data graph." The spec makes it explicit that sh:shapesGraph triples are declared in the data graph: "A data graph can include triples used to suggest one or more graphs to a SHACL processor with the predicate sh:shapesGraph."

So, for example when using https://www.itb.ec.europa.eu/shacl/shacl/upload for validation, my understanding is that I do not need to provide anything except a data graph containing

[] sh:shapesGraph <http://foo.bar/#> .

and this should automatically populate the shapes graph with the http://foo.bar/# shapes.

Judging by e.g. AllegroGraph docs, this is exactly what should happen: "If shape-graph-iri/s is not specified, the SHACL processor will first look to create the shapesGraph by finding triples with the predicate sh:shapesGraph in the dataGraph. If there are no such triples, then the shapesGraph will be assumed to be the same as the dataGraph."

However none of the open validators I tried (the EU ITB validator or Zazuko playground) react to sh:shapesGraph in any way (regardless of whether I declare it for a blank node or not), whereas owl:import from the same URL works perfectly.

Is this behaviour standardized at all? For such fundamental functionality I would assume all validators would act similarly.

Can someone shed a light and explain in mundane terms what I am missing here?


Solution

  • The idea of sh:shapesGraph was to enable data publishers to provide hints at which shapes should be applied to the data. Tools are invited but not required to follow this hint. Some APIs support this property but other tools that operate on explicit file upload may not look for it.

    So I believe your interpretation is correct but given that the sh:shapesGraph property has no strict formal semantics that are mandatory for engines, its coverage is incomplete. Note the "should" and "can" in the spec.

    FWIW what we do in practice when the intended shapes for a data graph are clear, we put the shapes into an ontology and just owl:import that ontology from the data graph(s). This has the effect that more APIs and tools would follow the owl:imports and therefore you get the shapes into the data graph. Then, if you leave the shapes graph "empty" most systems should assume that shapes graph = data graph and use the provided shapes.