-
Notifications
You must be signed in to change notification settings - Fork 4
/
sparql.vsp
170 lines (166 loc) · 7.28 KB
/
sparql.vsp
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?vsp
--
-- $Id$
--
-- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
-- project.
--
-- Copyright (C) 1998-2021 OpenLink Software
--
-- This project is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by the
-- Free Software Foundation; only version 2 of the License, dated June 1991.
--
-- This program is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
--
declare debug, def_qry, ini_dflt_graph, can_sponge any;
declare consumer_key, consumer_secret, oauth_token, oauth_secret, signature, timest, nonce varchar;
declare srv, res, signature_base, ret_url, url, tmp, sid, bin varchar;
declare meth, pars, hdr, content_type, host any;
declare cookie_str, cookie_vec any;
debug := get_keyword ('debug', params, case (get_keyword ('query', params, '')) when '' then '1' else '' end);
def_qry := cfg_item_value (virtuoso_ini_path (), 'SPARQL', 'DefaultQuery');
if (def_qry is null)
def_qry := 'SELECT * WHERE {?s ?p ?o} LIMIT 10';
ini_dflt_graph := cfg_item_value (virtuoso_ini_path (), 'SPARQL', 'DefaultGraph');
?><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Virtuoso SPARQL Query Form</title>
<style type="text/css">
label
{ display: inline; margin-top: 10pt; }
body { font-family: arial, helvetica, sans-serif; font-size: 9pt; color: #234; }
fieldset { border: 2px solid #86b9d9; }
legend { font-size: 12pt; color: #86b9d9; }
label { font-weight: bold; }
h1 { width: 100%; background-color: #86b9d9; font-size: 18pt; font-weight: normal; color: #fff; height: 4ex; text-align: right; vertical-align: middle; padding-right: 8px; }
</style>
<script language="JavaScript">
var last_format = 1;
function format_select(query_obg)
{
var query = query_obg.value;
var format = query_obg.form.format;
if (query.match(/construct/i) && last_format == 1) {
for(var i = format.options.length; i > 0; i--)
format.options[i] = null;
format.options[1] = new Option('N3/Turtle','text/rdf+n3');
format.options[2] = new Option('RDF/XML','application/rdf+xml');
format.selectedIndex = 1;
last_format = 2;
}
if (!query.match(/construct/i) && last_format == 2) {
for(var i = format.options.length; i > 0; i--)
format.options[i] = null;
format.options[1] = new Option('HTML','text/html');
format.options[2] = new Option('XML','application/sparql-results+xml');
format.options[3] = new Option('JSON','application/sparql-results+json');
format.options[4] = new Option('Javascript','application/javascript');
format.selectedIndex = 1;
last_format = 1;
}
}
</script>
</head>
<body>
<div id="header">
<h1>OpenLink Virtuoso SPARQL Query</h1>
</div>
<div id="main">
<p>This query page is designed to help you test OpenLink Virtuoso SPARQL protocol endpoint. <br/>
Consult the <a href="http://virtuoso.openlinksw.com/wiki/main/Main/VOSSparqlProtocol">Virtuoso Wiki page</a> describing the service
or the <a href="http://docs.openlinksw.com/virtuoso/">Online Virtuoso Documentation</a> section <a href="http://docs.openlinksw.com/virtuoso/rdfandsparql.html">RDF Database and SPARQL</a>.</p>
<p>There is also a rich Web based user interface with sample queries.
<?vsp if (DB.DBA.VAD_CHECK_VERSION('iSPARQL') is null) { ?>
In order to use it you must install the iSPARQL package (isparql_dav.vad).</p>
<?vsp } else { ?>
You can access it at: <a href="/isparql">/isparql</a>.</p>
<?vsp } ?>
<form action="/sparql" method="GET">
<fieldset>
<legend>Query</legend>
<label for="default-graph-uri">Default Graph URI</label>
<br />
<input type="text" name="default-graph-uri" id="default-graph-uri" value="<?V ini_dflt_graph ?>" size="80"/>
<br /><br />
<?vsp if (can_sponge)
{
declare s_param varchar;
s_param := get_keyword ('should-sponge', params, '');
?>
<select name="should-sponge" id="should-sponge">');
<option <?V case (s_param) when '' then ' selected="selected"' else '' end ?> value="">Use only local data (including data retrieved before), but do not retrieve more</option>
<option <?V case (s_param) when 'soft' then ' selected="selected"' else '' end ?> value="soft">Retrieve remote RDF data for all missing source graphs</option>
<option <?V case (s_param) when 'grab-all' then ' selected="selected"' else '' end ?> value="grab-all">Retrieve all missing remote RDF data that might be useful</option>
<option <?V case (s_param) when 'grab-seealso' then ' selected="selected"' else '' end ?> value="grab-all-seealso">Retrieve all missing remote RDF data that might be useful, including seeAlso references</option>
<option <?V case (s_param) when 'grab-everything' then ' selected="selected"' else '' end ?> value="grab-everything">Try to download all referenced resources (this may be very slow and inefficient)</option>
</select>
<br />
<?vsp }
else
{
declare host_ur varchar;
host_ur := registry_get ('URIQADefaultHost');
?>
<i>Security restrictions of this server do not allow you to retrieve remote RDF data.
DBA may wish to grant "SPARQL_SPONGE" privilege to "SPARQL" account to remove the restriction.
In order to do this, please perform the following steps:</i>
<br />
1. Go to the Virtuoso Administration Conductor i.e.
<?vsp
if (not isstring (host_ur))
{
htt ('http://host:port/conductor');
}
else
{
http(sprintf('http://%s/conductor',host_ur));
};
?>
<br />
2. Login as dba user
<br />
3. Go to System Admin->User Accounts->Roles
<br />
4. Click the link "Edit" for "SPARQL_SPONGE"
<br />
5. Select from the list of available user/groups "SPARQL" and click the ">>" button so to add it to the right-positioned list.
<br />
6. Click the button "Update"
<br />
7. Access again the sparql endpoint in order to be able to retrieve remote data.
<br /><br />
<?vsp } ?>
<label for="query">Query text</label>
<br />
<textarea rows="10" cols="60" name="query" id="query" onchange="format_select(this)"
onkeyup="format_select(this)"><?V coalesce (get_keyword ('q', params), def_qry, '') ?></textarea>
<br /><br />
<label for="format" class="n">Display Results As:</label>
<select name="format">
<option value="auto">Auto</option>
<option value="text/html" selected="selected">HTML</option>
<option value="application/vnd.ms-excel">Spreadsheet</option>
<option value="application/sparql-results+xml">XML</option>
<option value="application/sparql-results+json">JSON</option>
<option value="application/javascript">Javascript</option>
</select>
<input name="debug" type="checkbox" <?V case (debug) when '' then '' else ' checked' end ?>/>
<label for="debug" class="n">Rigorous check of the query</label>
<input type="submit" value="Run Query" name="rt"/>
<input type="submit" value="End session" name="es"/>
<input type="reset" value="Reset"/>
</fieldset>
</form>
</div>
</body>
</html>