Skip to content

Commit b2a52c4

Browse files
authored
Merge pull request #34 from meaningfy-ws/feature/DIF1-17_shacl-info
Initial support for fetching embedded SHACL info in OWL
2 parents b6d8ed0 + 6ba3b0e commit b2a52c4

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)