-
Couldn't load subscription status.
- Fork 37
Description
Within a Graph, we may wish to find all the Shapes that a Profile depends on.
Context
I have a database containing lots of Shapes that are defined in Profiles (instances of owl:Ontology) with lots of Shapes reuse between Profiles and I want to know about Shape dependency so I can work out the effects of Shapes' change on Profiles, Profile similarity Profile --> Profile dependency.
This scenario exists in a couple of projects of mine already where we have built up lots of Profiles using Shapes for large, diverse, Knowledge Graphs.
Postconditions
- The Actor will need to be able to differentiate between Profiles that define Shapes and Profiles that just reuse them so they can work out what Profiles are able to change what Shapes
- The Actor must be able to find Shapes defined by no Profile, or Shapes defined without knowledge of any containing Profile, if they are depended upon by their Profile(s) of interest
Solution
Link Shapes to the Profiles that define them with rdfs:isDefinedBy
Link Shapes to Profiles that use them but do not define them with rdfs:member
Testing Example
Data
---
config:
layout: dagre
title: Node
---
flowchart LR
Profile-M["Profile M"] -- defines --> n1["Shape A"] & n2["Shape B"]
Profile-N["Profile N"] -- defines --> n3["Shape C"]
Profile-N -- uses --> n2
Profile-O["Profile O"] -- uses --> n3 & n5["Shape D"]
Profile-O -- defines --> n4["Shape E"]
n1@{ shape: rect}
n2@{ shape: rect}
n3@{ shape: rect}
n5@{ shape: rect}
n4@{ shape: rect}
# Profiles
ex:prof-M
a owl:Ontology ;
.
ex:prof-N
a owl:Ontology ;
.
ex:prof-O
a owl:Ontology ;
.
# Shapes
ex:shape-A
a sh:NodeShape ;
rdfs:isDefinedBy ex:prof-m ;
.
ex:shape-B
a sh:NodeShape ;
rdfs:isDefinedBy ex:prof-M ;
rdfs:member ex:prof-N ;
.
ex:shape-C
a sh:NodeShape ;
rdfs:isDefinedBy ex:prof-N ;
rdfs:member ex:prof-O ;
.
ex:shape-D
a sh:NodeShape ;
rdfs:member ex:prof-O ;
.
ex:shape-E
a sh:NodeShape ;
rdfs:isDefinedBy ex:prof-O ;
.In the data above, the Actor will be able to discover that Profile O:
- defines Shape E
- depends on Shape C
- depends on Shape D
- transitively depends on Profile N as the definer of Shape C
Find all the Shapes defined by Profile O:
SELECT ?shp
WHERE {
VALUES ?shp_type { sh:NodeShape sh:PropertyShape }
?shp
a ?shp_type ;
rdfs:isDefinedBy ex:prof-O ;
.
}
Find all the Shapes depended upon, but not defined by, Profile O:
SELECT ?shp
WHERE {
VALUES ?shp_type { sh:NodeShape sh:PropertyShape }
?shp
a ?shp_type ;
rdfs:member ex:prof-O ;
.
MINUS {
?shp rdfs:isDefinedBy ex:prof-O
}
}