-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.py
More file actions
28 lines (21 loc) · 781 Bytes
/
test.py
File metadata and controls
28 lines (21 loc) · 781 Bytes
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
import rdflib
g = rdflib.Graph()
g.parse('build-local/tests/api/records/v1/schemas/linkTemplate/var-exists-fail.ttl', format='turtle')
# Define the SPARQL query
query = """
PREFIX rec: <https://www.opengis.net/def/ogc-api/records/>
prefix oa: <http://www.w3.org/ns/oa#>
SELECT COUNT(?var)
WHERE {
BIND (rec:hasVariable as ?path)
$this rec:hasVariable/dct:identifier ?var .
$this rec:uriTemplate ?template .
}
GROUP BY $this ?path ?value ?template
"""
# Run the query against the local graph
qres = g.query(query)
for row in qres:
print(f"Subject: {row.s}, Predicate: {row.p}, Object: {row.o}")
# Or by index:
# print(f"Subject: {row[0]}, Predicate: {row[1]}, Object: {row[2]}")