source: gs2-extensions/apache-jena/trunk/src/transform/pages/sparql.xsl@ 37138

Last change on this file since 37138 was 37138, checked in by davidb, 17 months ago

Generic sparql.xsl that will work when added in to a collection

  • Property svn:executable set to *
File size: 9.4 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 xmlns:java="http://xml.apache.org/xslt/java"
5 xmlns:util="xalan://org.greenstone.gsdl3.util.XSLTUtil"
6 xmlns:gslib="http://www.greenstone.org/skinning"
7 xmlns:gsf="http://www.greenstone.org/greenstone3/schema/ConfigFormat"
8 extension-element-prefixes="java util"
9 exclude-result-prefixes="java util">
10
11
12 <!-- use the 'main' layout -->
13 <xsl:import href="layouts/main.xsl"/>
14
15 <xsl:variable name="groupPath"><xsl:value-of select="/page/pageRequest/paramList/param[@name='group']/@value"/></xsl:variable>
16
17 <xsl:variable name="siteURL"><xsl:value-of select="/page/pageResponse/metadataList/metadata[@name = 'siteURL']" /></xsl:variable>
18 <xsl:variable name="sparqlEndpointProtocol">http</xsl:variable>
19
20 <xsl:variable name="fuseki3ServletProtocol">
21 <xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name = 'fuseki3_servlet_protocol']/@value"/>
22 </xsl:variable>
23 <xsl:variable name="fuseki3ServletDomain">
24 <xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name = 'fuseki3_servlet_domain']/@value"/>
25 </xsl:variable>
26 <xsl:variable name="fuseki3ServletOptPort">
27 <xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name = 'fuseki3_servlet_opt_port']/@value"/>
28 </xsl:variable>
29 <xsl:variable name="fuseki3ServletContext">
30 <xsl:value-of select="/page/pageResponse/interfaceOptions/option[@name = 'fuseki3_servlet_context']/@value"/>
31 </xsl:variable>
32
33
34
35 <!-- Apache Jena Fuseki v3 -->
36
37 <!--
38 <xsl:variable name="sparqlEndpointHostAndOptPort">localhost:4040</xsl:variable>
39 <xsl:variable name="sparqlGraphBasePrefix">http://localhost:8383</xsl:variable>
40
41 <xsl:variable name="sparqlEndpointPrefix1"></xsl:variable>
42 <xsl:variable name="sparqlEndpointPrefix3"></xsl:variable>
43 <xsl:variable name="sparqlEndpoint3">http://localhost:4040</xsl:variable>
44
45 <xsl:variable name="graphURI"><xsl:value-of select="$sparqlGraphBasePrefix"/><xsl:value-of select="$siteURL"/><xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="$collName"/></xsl:variable>
46 -->
47
48 <!--
49 <xsl:variable name="sparqlEndpointHostAndOptPort">intermuse.sowemustthink.space</xsl:variable>
50 <xsl:variable name="sparqlGraphBasePrefix">https://intermuse.so-we-must-think.space</xsl:variable> < ! - - FULL_GREENSTONE_URL_PREFIX marker --> <!-- This marker can only appear ONCE in file, as it is processed by sed - - >
51
52 <xsl:variable name="sparqlEndpointPrefix1">/greenstone3-lod</xsl:variable>
53 <xsl:variable name="sparqlEndpointPrefix3">/greenstone3-lod3</xsl:variable>
54 <xsl:variable name="sparqlEndpoint3">https://intermuse.sowemustthink.space/greenstone3-lod3</xsl:variable>
55
56 <xsl:variable name="graphURI"><xsl:value-of select="$sparqlGraphBasePrefix"/><xsl:value-of select="$siteURL"/><xsl:value-of select="$site_name"/>-library/collection/<xsl:value-of select="$collName"/></xsl:variable>
57 -->
58
59
60 <xsl:variable name="sparqlEndpointHostAndOptPort"><xsl:value-of select="$fuseki3ServletDomain"/><xsl:if test="$fuseki3ServletOptPort != ''">:<xsl:value-of select="$fuseki3ServletOptPort"/></xsl:if></xsl:variable>
61 <xsl:variable name="sparqlGraphBasePrefix"><xsl:value-of select="$fuseki3ServletProtocol"/>://<xsl:value-of select="$fuseki3ServletDomain"/></xsl:variable>
62 <xsl:variable name="sparqlEndpointPrefix3"><xsl:value-of select="$fuseki3ServletContext"/></xsl:variable>
63 <xsl:variable name="sparqlEndpoint3"><xsl:value-of select="$fuseki3ServletProtocol"/>://<xsl:value-of select="$fuseki3ServletDomain"/><xsl:value-of select="$sparqlEndpointPrefix3"/></xsl:variable>
64
65 <xsl:variable name="graphURI"><xsl:value-of select="$sparqlGraphBasePrefix"/><xsl:value-of select="$siteURL"/>/<xsl:value-of select="$servletContext"/>/<xsl:value-of select="$library_name"/>/collection/<xsl:value-of select="$collName"/></xsl:variable>
66
67
68
69 <!-- set page title -->
70 <xsl:template name="pageTitle">SPARQL Query</xsl:template>
71
72 <!-- set page breadcrumbs -->
73 <xsl:template name="breadcrumbs"><gslib:siteLink/><gslib:rightArrow/>
74 <xsl:if test="$groupPath != ''">
75 <xsl:for-each select="/page/pageResponse/pathList/group">
76 <xsl:sort data-type="number" select="@position"/>
77 <a>
78 <xsl:attribute name="href"><gslib:groupHref path="{@path}"/></xsl:attribute>
79 <xsl:attribute name="title"><gslib:groupName path="{@path}"/></xsl:attribute>
80 <gslib:groupName path="{@path}"/>
81 </a>
82 <gslib:rightArrow/>
83 </xsl:for-each>
84 </xsl:if>
85 <a href="{$library_name}/collection/{$collName}/page/about"><gslib:collectionName/></a>
86 </xsl:template>
87
88 <!-- the page content -->
89 <xsl:template match="/page">
90 <!--
91 <link rel="stylesheet" href="sites/{$site_name}/collect/{$collName}/style/fuseki.css" type="text/css" />
92 -->
93 <gsf:script src="sites/{$site_name}/collect/{$collName}/js/jquery.show-more.js"/>
94 <gsf:script src="sites/{$site_name}/collect/{$collName}/js/dataviz.js"/>
95
96 <!--
97 <link rel="stylesheet" href="sites/{$site_name}/collect/{$collName}/css/eurovision.css" type="text/css" />
98 -->
99 <gsf:style src="sites/{$site_name}/collect/{$collName}/css/dataviz.css" />
100
101 <div>
102 <h2>Query the Linked-Data and let its values Sparkle (aka SPARQL)</h2>
103
104 <p>
105 Using this page you can query the linked-data in the
106 Greenstone3 triplestore graph using
107 <a href="https://en.wikipedia.org/wiki/SPARQL">SPARQL</a>
108 query syntax. The default query provided in the text
109 box below is effectively issuing a query that returns
110 everything stored (a bit like matching with the wildcard
111 '*' that some text-based search systems have), limited
112 to show just the first 500 entries that matched.
113 </p>
114
115 <p>
116 Use the default query to get a feel for the data that is
117 stored. Feel free to experiment with the syntax to vary
118 what is returned. For example, to view other "slices"
119 of the rows of data returned, change the values of
120 OFFSET and LIMIT. OFFSET controls how many result rows
121 are skipped over before rows are selected. LIMIT
122 controls how many rows are then taken.
123
124 </p>
125
126 <div id="sparql-show-more" class="showmore">
127 <p>
128 Alternatively, you might be interested in experimenting
129 with forms of access to the triplestore through the more powerful, but complex:
130 <ul>
131 <li>
132 <!-- endpoint -->
133 <a target="_blank" href="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/dataset.html?tab=query&amp;ds=/greenstone">Fuseki interface</a>
134
135 </li>
136 </ul>
137 </p>
138 <p>
139 Or else export the entire triplestore to work on it with whichever Linked Data tools are your preference:
140 <ul>
141 <li>
142 <!-- endpoint -->
143 <a href="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/greenstone/data" download="greenstone3-{$collNameChecked}-lod.trig">Full Export in TriG Syntax</a>
144
145 </li>
146 <li>
147 <!-- endpoint -->
148 <a href="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/greenstone/data" download="greenstone3-{$collNameChecked}-lod.ttl">Full Export in Turtle Syntax</a>
149 <!--
150 //{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/greenstone/data
151 -->
152 </li>
153 </ul>
154 </p>
155
156 </div>
157 <gsf:script>
158 $('#sparql-show-more').showMore({
159 minheight: 0,
160 buttontxtmore:"show more ...",
161 buttontxtless:"... show less"
162 });
163 </gsf:script>
164
165 </div>
166 <div>
167 <h2>SPARQL Query</h2>
168 <!--
169 <p>
170 Dataset: /greenstone<br/>
171 Graph: eurovision
172 </p>
173 -->
174
175 </div>
176
177 <div class="moreindent">
178 <!-- endpoint -->
179 <form id="sample-sparql-query-form"
180 action="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/greenstone/query" target="_blank"
181 method="POST" accept-charset="UTF-8">
182
183 <textarea id="sample-sparql-query" name="query" style="width:100%; min-width:100%; max-width: 100%;" rows="14">
184<!-- -->
185<xsl:text>
186PREFIX gsdlextracted: &lt;http://greenstone.org/gsdlextracted#&gt;
187
188SELECT ?subject ?predicate ?object WHERE {
189 GRAPH &lt;</xsl:text><xsl:value-of select="$graphURI"/><xsl:text>&gt; {
190 ?subject ?predicate ?object.
191 }
192}
193OFFSET 0 LIMIT 500
194</xsl:text>
195 </textarea>
196 <div style="display:none;">
197 <div>
198 Output:
199 <select name="output">
200 <option value="text">Text</option>
201 <option value="json">JSON</option>
202 <option value="xml" selected="selected">XML</option>
203 <option value="csv">CSV</option>
204 <option value="tsv">TSV</option>
205 </select>
206 </div>
207
208 <div>
209 If XML output, add XSLT style sheet (blank for none):
210 <select name="stylesheet">
211 <option value=""></option>
212 <!-- endpoint -->
213 <option value="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/xml-to-html.xsl">xml-to-html</option>
214 <option value="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/xml-to-html-links.xsl" selected="selected">xml-to-html-links</option>
215 <option value="//{$sparqlEndpointHostAndOptPort}{$sparqlEndpointPrefix3}/xml-to-html-plain.xsl">xml-to-html-plain</option>
216 </select>
217 </div>
218
219 <div>
220 <input type="checkbox" name="force-accept" value="text/plain" />
221 Force the accept header to <tt>text/plain</tt> regardless.
222 </div>
223 </div>
224
225 <div style="padding-top: 6px;">
226 <input type="submit" value="Get Results" />
227 </div>
228
229 </form>
230 </div>
231
232
233 </xsl:template>
234
235
236</xsl:stylesheet>
237
Note: See TracBrowser for help on using the repository browser.