This repository has been archived by the owner on Jul 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
skos-alpha.xsl
105 lines (91 loc) · 3.24 KB
/
skos-alpha.xsl
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:results="http://www.w3.org/2005/sparql-results#"
xmlns:sparql="http://berrueta.net/research/xsltsparql"
version="2.0">
<xsl:function name="sparql:prefixes">
<xsl:value-of select="concat(
'PREFIX owl: <http://www.w3.org/2002/07/owl#> ',
'PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> ',
'PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> ',
'PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ',
'PREFIX foaf: <http://xmlns.com/foaf/0.1/> ',
'PREFIX dc: <http://purl.org/dc/elements/1.1/> ',
'PREFIX skos: <http://www.w3.org/2004/02/skos/core#> ')" />
</xsl:function>
<xsl:function name="sparql:sparql">
<xsl:param name="query"/>
<xsl:param name="endpointUrl"/>
<xsl:variable name="encodedQuery" select="encode-for-uri($query)"/>
<xsl:variable name="requestedUrl" select="concat($endpointUrl,'?query=',$encodedQuery)"/>
<xsl:variable name="endpointResponse" select="document($requestedUrl)"/>
<xsl:if test="not($endpointResponse/results:sparql)">
<xsl:message>The response does not contain <sparql:sparql> in the root!</xsl:message>
<xsl:message>Results: <xsl:copy-of select="$endpointResponse"/></xsl:message>
</xsl:if>
<xsl:copy-of select="$endpointResponse/results:sparql"/>
</xsl:function>
<!-- BEGIN of configuration parameters -->
<!-- The language of thesaurus. Only one language can be displayed at
a time, so you have to choose what language do you want. Use the
empty string for the default language -->
<xsl:param name="lang" select="'fr'"/>
<xsl:param name="endpoint" select="'http://localhost:5151/sparql'" />
<!-- END of configuration parameters -->
<xsl:template match="/">
<html>
<head>
<title>Vocabulary : alphabetical index</title>
<style type="text/css">
.prefLabel {
font-weight:bold;
}
.description {
font-size:-1;
}
.abbr {
font-weight:bold;
}
</style>
</head>
<body>
<h1>Vocabulary: alphabetical index</h1>
<ul class="vocabulary">
<xsl:apply-templates
select="sparql:sparql(
concat(
sparql:prefixes(),
'SELECT ?concept ?label ?prefLabel
WHERE {
{ ?concept skos:prefLabel ?label }
UNION
{
?concept skos:prefLabel ?prefLabel .
?concept skos:altLabel ?label
} .
FILTER (lang(?label) = "',
$lang,
'") }'
),
$endpoint
)/results:results/results:result"
mode="entry">
<xsl:sort select="results:binding[@name='label']"/>
</xsl:apply-templates>
</ul>
</body>
</html>
</xsl:template>
<xsl:template match="results:result" mode="entry">
<li>
<xsl:choose>
<xsl:when test="results:binding[@name='prefLabel']">
<span class="altLabel"><xsl:value-of select="results:binding[@name='label']"/></span>
<ul class="use"><li>
<xsl:text>USE </xsl:text><xsl:value-of select="results:binding[@name='prefLabel']"/>
</li></ul>
</xsl:when>
</xsl:choose>
</li>
</xsl:template>
</xsl:stylesheet>