I would like to add a validation (using SHACL or ADS) to verify that the depth of my taxonomy does not exceed a preset limit. This should ideally be able to handle a multi-hierarchy (if that is the correct term), calculating the maximum depth where any concept appears.
One approach would be to infer a :depth property using the following basic logic
[?concept, :depth, 1] :-
[?concept, skos:topConceptOf, ?scheme].
[?concept, :depth, ?depth] :-
[?concept, skos:broader, ?parent],
[?parent, :depth, ?parentDepth],
BIND(?parentDepth + 1 as ?depth).
And then use SHACL to set a max value on this property. Is there a way to accomplish this using sh:values?
It would be challenging to do this with a query-based constraint as a string count of transitive parents does not handle multi-hierarchies well. Perhaps an ADS-based JS validator that walks up the tree finding the longest path to the ConceptScheme - are those relationships easily available from the focusNode NamedNode provided to the JS rule?