Skip to content

Commit 6ba3b0e

Browse files
committed
feat: initial support for fetching embedded SHACL info in OWL
Support fetching domain, range and cardinality information from vocabularies containing a SHACL graph. The queries are different depending on whether it is an object property or a datatype property. Where the information isn't available, there will be empty cells in the report. There is also support for value node constraints for certain patterns of expressing ranges for IRIs with `sh:hasValue`, such as SKOS vocabularies, used for example in recent versions of the eProcurement ontology (ePO): ```ttl sh:nodeKind sh:IRI ; sh:node [ rdf:type sh:NodeShape ; sh:property [ sh:path skos:inScheme ; sh:hasValue atold:language ; ] ; ] . ``` Currently, this feature is NOT for capturing changes in the domain, range and cardinality, and is only for the case of ADDED instances of such resources, not their modifications. The information won't show up for individual property changes on the resources (added/updated/changed/moved labels and the whole shebang). The queries in those cases will differ between modification types, and there is the question of how to fit all of the information in an already-crowded table. Work will continue on how best to approach this. P.S: There are nested OPTIONALs as the graph may not exist, so performance may be affected, though hopefully not by too much. If that becomes a concern, we can turn these over onto a new template, where a SHACL graph would be made mandatory.
1 parent 84be741 commit 6ba3b0e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

dqgen/resources/query_templates/instance_additions.rq

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ PREFIX sd: <http://www.w3.org/ns/sparql-service-description#>
3636
PREFIX sh: <http://purl.org/skos-history/>
3737
PREFIX xhv: <http://www.w3.org/1999/xhtml/vocab#>
3838
# identify added instances
39+
{% if cls == "owl:ObjectProperty" or cls == "owl:DatatypeProperty" %}
40+
SELECT distinct ?class ?instance ?prefLabel ?prefLabelLang ?domain ?range ?minCardinality ?maxCardinality ("{{type_of_action}}" as ?actionType)
41+
{% else %}
3942
SELECT distinct ?class ?instance ?prefLabel ?prefLabelLang ("{{type_of_action}}" as ?actionType)
43+
{% endif %}
4044
WHERE {
4145
GRAPH ?versionHistoryGraph {
4246
# parameters
@@ -143,5 +147,39 @@ WHERE {
143147
?instance ?p [] .
144148
}
145149
}
150+
{% if cls == "owl:ObjectProperty" %}
151+
# and we get some domain, range and cardinality information from SHACL shapes if available
152+
OPTIONAL {
153+
GRAPH ?newVersionGraph {
154+
{
155+
?nodeShape shacl:property ?propertyShape ;
156+
shacl:targetClass ?domain .
157+
?propertyShape shacl:path ?instance ;
158+
shacl:class ?range .
159+
}
160+
UNION
161+
{
162+
?nodeShape shacl:property ?propertyShape ;
163+
shacl:targetClass ?domain .
164+
?propertyShape shacl:path ?instance ;
165+
shacl:node/shacl:property/shacl:hasValue ?range .
166+
}
167+
OPTIONAL { ?propertyShape shacl:minCount ?minCardinality }
168+
OPTIONAL { ?propertyShape shacl:maxCount ?maxCardinality }
169+
}
170+
}
171+
{% elif cls == "owl:DatatypeProperty" %}
172+
# and we get some domain, range and cardinality information from SHACL shapes if available
173+
OPTIONAL {
174+
GRAPH ?newVersionGraph {
175+
?nodeShape shacl:property ?propertyShape ;
176+
shacl:targetClass ?domain .
177+
?propertyShape shacl:path ?instance ;
178+
shacl:datatype ?range .
179+
OPTIONAL { ?propertyShape shacl:minCount ?minCardinality }
180+
OPTIONAL { ?propertyShape shacl:maxCount ?maxCardinality }
181+
}
182+
}
183+
{% endif %}
146184
}
147185
ORDER BY ?instance

0 commit comments

Comments
 (0)