-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelevant-quads.sparql
More file actions
86 lines (76 loc) · 2.73 KB
/
relevant-quads.sparql
File metadata and controls
86 lines (76 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
PREFIX sh: <http://www.w3.org/ns/shacl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
CONSTRUCT {
?shapeIri sh:property ?propShape .
?shapeIri sh:closed ?closed .
?shapeIri sh:or ?orHead .
?shapeIri sh:xone ?xoneHead .
?shapeIri sh:not ?notTarget .
?propShape sh:path ?path .
?propShape sh:minCount ?minCount .
?propShape sh:maxCount ?maxCount .
?propShape sh:class ?class .
?propShape sh:datatype ?datatype .
?propShape sh:node ?node .
?notTarget sh:path ?notPath .
?notTarget sh:minCount ?notMin .
?notTarget sh:maxCount ?notMax .
?notTarget sh:class ?notClass .
?notTarget sh:datatype ?notDatatype .
?notTarget sh:node ?notNode .
?listNode rdf:first ?listMember .
?listNode rdf:rest ?listNext .
?listMember sh:property ?memberPropShape .
?listMember sh:path ?memberDirectPath .
?memberPropShape sh:path ?memberPath .
?memberPropShape sh:minCount ?memberMin .
?memberPropShape sh:maxCount ?memberMax .
?memberPropShape sh:class ?memberClass .
?memberPropShape sh:datatype ?memberDatatype .
?memberPropShape sh:node ?memberNode .
}
WHERE {
<GRAPH_SCOPE> {
BIND(<SHAPE_IRI> AS ?shapeIri)
# Direct property shapes
OPTIONAL {
?shapeIri sh:property ?propShape .
OPTIONAL { ?propShape sh:path ?path }
OPTIONAL { ?propShape sh:minCount ?minCount }
OPTIONAL { ?propShape sh:maxCount ?maxCount }
OPTIONAL { ?propShape sh:class ?class }
OPTIONAL { ?propShape sh:datatype ?datatype }
OPTIONAL { ?propShape sh:node ?node }
}
# sh:closed
OPTIONAL { ?shapeIri sh:closed ?closed }
# sh:not
OPTIONAL {
?shapeIri sh:not ?notTarget .
OPTIONAL { ?notTarget sh:path ?notPath }
OPTIONAL { ?notTarget sh:minCount ?notMin }
OPTIONAL { ?notTarget sh:maxCount ?notMax }
OPTIONAL { ?notTarget sh:class ?notClass }
OPTIONAL { ?notTarget sh:datatype ?notDatatype }
OPTIONAL { ?notTarget sh:node ?notNode }
}
# sh:or / sh:xone RDF list + members
OPTIONAL {
{ ?shapeIri sh:or ?orHead } UNION { ?shapeIri sh:xone ?xoneHead }
BIND(COALESCE(?orHead, ?xoneHead) AS ?listHead) # continue with just ?listHead
?listHead rdf:rest* ?listNode . # every ?listNode starting from ?listhead (including itself)
?listNode rdf:first ?listMember ;
rdf:rest ?listNext .
OPTIONAL {
?listMember sh:property ?memberPropShape .
OPTIONAL { ?memberPropShape sh:path ?memberPath }
OPTIONAL { ?memberPropShape sh:minCount ?memberMin }
OPTIONAL { ?memberPropShape sh:maxCount ?memberMax }
OPTIONAL { ?memberPropShape sh:class ?memberClass }
OPTIONAL { ?memberPropShape sh:datatype ?memberDatatype }
OPTIONAL { ?memberPropShape sh:node ?memberNode }
}
OPTIONAL { ?listMember sh:path ?memberDirectPath }
}
}
}