-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheugm.html
75 lines (66 loc) · 3.08 KB
/
eugm.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>EUGM codelists - table</title>
</head>
<body>
<div id="heading">
<h1>
EUGM dictionary
</h1>
</div>
<div id="table"></div>
<script>
const tblArr = ['12652', '12590', '12628', '12646', '12728', '12678', '12688', '12684', '12694', '12672', '12698', '12705', '12720', '12724', '12713'];
let query = `PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
PREFIX eugm: <https://voc.europe-geology.eu/gseu/eugm/>
select distinct ?URI ?Label
(GROUP_CONCAT(distinct ?n; separator = '; ') as ?Notation)
(GROUP_CONCAT(distinct ?a; separator = '; ') as ?altLabel)
(GROUP_CONCAT(distinct ?D; separator = '; ') as ?Definition)
(GROUP_CONCAT(distinct ?P; separator = '; ') as ?Parent)
(GROUP_CONCAT(distinct ?N; separator = '; ') as ?scopeNote)
where {
eugm:§ skos:narrower* ?URI .
?URI skos:prefLabel ?Label . filter(lang(?Label)="en")
optional {?URI skos:notation ?n}
optional {?URI skos:altLabel ?a}
optional {?URI skos:definition ?D filter(lang(?D)="en")}
optional {?URI skos:scopeNote ?N filter(lang(?N)="en")}
optional {?URI skos:broader ?o . ?o skos:prefLabel ?P filter(lang(?P)="en")}
}
group by ?URI ?Label
order by ?URI`;
//***********************HTML Table download***************************************
for (const i of tblArr) {
fetch('https://resource.geosphere.at/graphdb/repositories/GSEU?query=' + encodeURIComponent(query.replace('§',i)) + '&Accept=application%2Fsparql-results%2Bjson')
.then(res => res.json())
.then(jsonData => {
let s = 'border: 1px solid black; border-collapse: collapse; word-wrap: break-all; padding:5px; margin: 25px 0px 25px 0px;';
let rows = jsonData.head.vars; //console.log(rows);
document.getElementById('table').innerHTML += `<h2><a href="${jsonData.results.bindings[0].URI.value}">` + jsonData.results.bindings[0].Label.value + '</a></h2>';
let tbl = `<table style="${s}" class="table table-hover">
<thead>
<tr style="${s}">
<th style="${s}">${rows.join(`</th>
<th style="${s}">`)}</th>
</tr>
</thead>
<tbody>
${jsonData.results.bindings.slice(1)
.map(a => `<tr style="${s}">` +
rows.map(c => `<td style="${s}${c=='Definition'||c=='scopeNote'?'font-size:70%;':''}">` +
createLink(a[c].value) + '</td>').join() + '</tr>').join()}
</tbody>
</table>`;
document.getElementById('table').innerHTML += tbl.replace(/,/g,'') + '<hr>';
console.log(jsonData.results.bindings);
});
}
function createLink(txt){
return txt.substring(0, 4) == 'http' ? '<a href="' + txt + '">' + txt + '</a>' : txt
}
</script>
</body>
</html>