activerdf_sparql 1.3.3 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +4 -1
- data/doc/rdoc/classes/SparqlAdapter.html +240 -0
- data/doc/rdoc/classes/SparqlAdapter.src/M000001.html +31 -0
- data/doc/rdoc/classes/SparqlAdapter.src/M000002.html +18 -0
- data/doc/rdoc/classes/SparqlAdapter.src/M000003.html +20 -0
- data/doc/rdoc/classes/SparqlAdapter.src/M000004.html +55 -0
- data/doc/rdoc/classes/SparqlAdapter.src/M000005.html +18 -0
- data/doc/rdoc/classes/SparqlResultParser.html +236 -0
- data/doc/rdoc/classes/SparqlResultParser.src/M000006.html +20 -0
- data/doc/rdoc/classes/SparqlResultParser.src/M000007.html +27 -0
- data/doc/rdoc/classes/SparqlResultParser.src/M000008.html +23 -0
- data/doc/rdoc/classes/SparqlResultParser.src/M000009.html +20 -0
- data/doc/rdoc/classes/SparqlResultParser.src/M000010.html +25 -0
- data/doc/rdoc/classes/SparqlResultParser.src/M000011.html +17 -0
- data/doc/rdoc/created.rid +1 -0
- data/doc/rdoc/files/LICENSE.html +756 -0
- data/doc/rdoc/files/README.html +123 -0
- data/doc/rdoc/files/lib/activerdf_sparql/init_rb.html +114 -0
- data/doc/rdoc/files/lib/activerdf_sparql/sparql_rb.html +113 -0
- data/doc/rdoc/files/lib/activerdf_sparql/sparql_result_parser_rb.html +107 -0
- data/doc/rdoc/fr_class_index.html +28 -0
- data/doc/rdoc/fr_file_index.html +31 -0
- data/doc/rdoc/fr_method_index.html +37 -0
- data/doc/rdoc/index.html +24 -0
- data/doc/rdoc/rdoc-style.css +208 -0
- data/lib/activerdf_sparql/sparql.rb +1 -1
- data/lib/activerdf_sparql/sparql_result_parser.rb +1 -1
- metadata +86 -51
data/CHANGELOG
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
== activerdf_sparql (1.3.
|
|
1
|
+
== activerdf_sparql (1.3.4) Fri, 21 Sep 2007 10:06:57 +0100
|
|
2
|
+
* parse bnodes in SPARQL queries
|
|
3
|
+
|
|
4
|
+
== activerdf_sparql (1.3.3) 2007-09-03 15:37
|
|
2
5
|
* change Rakefile: require json_pure when running on JRuby
|
|
3
6
|
* added very simple close method to sparql adapter
|
|
4
7
|
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<title>Class: SparqlAdapter</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
// <![CDATA[
|
|
14
|
+
|
|
15
|
+
function popupCode( url ) {
|
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toggleCode( id ) {
|
|
20
|
+
if ( document.getElementById )
|
|
21
|
+
elem = document.getElementById( id );
|
|
22
|
+
else if ( document.all )
|
|
23
|
+
elem = eval( "document.all." + id );
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
|
|
27
|
+
elemStyle = elem.style;
|
|
28
|
+
|
|
29
|
+
if ( elemStyle.display != "block" ) {
|
|
30
|
+
elemStyle.display = "block"
|
|
31
|
+
} else {
|
|
32
|
+
elemStyle.display = "none"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Make codeblocks hidden by default
|
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
+
|
|
41
|
+
// ]]>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<div id="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Class</strong></td>
|
|
53
|
+
<td class="class-name-in-header">SparqlAdapter</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../files/lib/activerdf_sparql/sparql_rb.html">
|
|
59
|
+
lib/activerdf_sparql/sparql.rb
|
|
60
|
+
</a>
|
|
61
|
+
<br />
|
|
62
|
+
</td>
|
|
63
|
+
</tr>
|
|
64
|
+
|
|
65
|
+
<tr class="top-aligned-row">
|
|
66
|
+
<td><strong>Parent:</strong></td>
|
|
67
|
+
<td>
|
|
68
|
+
ActiveRdfAdapter
|
|
69
|
+
</td>
|
|
70
|
+
</tr>
|
|
71
|
+
</table>
|
|
72
|
+
</div>
|
|
73
|
+
<!-- banner header -->
|
|
74
|
+
|
|
75
|
+
<div id="bodyContent">
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
<div id="contextContent">
|
|
80
|
+
|
|
81
|
+
<div id="description">
|
|
82
|
+
<p>
|
|
83
|
+
SPARQL adapter
|
|
84
|
+
</p>
|
|
85
|
+
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<div id="method-list">
|
|
92
|
+
<h3 class="section-bar">Methods</h3>
|
|
93
|
+
|
|
94
|
+
<div class="name-list">
|
|
95
|
+
<a href="#M000005">close</a>
|
|
96
|
+
<a href="#M000004">execute_sparql_query</a>
|
|
97
|
+
<a href="#M000001">new</a>
|
|
98
|
+
<a href="#M000003">query</a>
|
|
99
|
+
<a href="#M000002">size</a>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
<!-- if includes -->
|
|
107
|
+
|
|
108
|
+
<div id="section">
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
<div id="attribute-list">
|
|
115
|
+
<h3 class="section-bar">Attributes</h3>
|
|
116
|
+
|
|
117
|
+
<div class="name-list">
|
|
118
|
+
<table>
|
|
119
|
+
<tr class="top-aligned-row context-row">
|
|
120
|
+
<td class="context-item-name">engine</td>
|
|
121
|
+
<td class="context-item-value"> [R] </td>
|
|
122
|
+
<td class="context-item-desc">
|
|
123
|
+
Instantiate the connection with the SPARQL Endpoint. available parameters:
|
|
124
|
+
|
|
125
|
+
<ul>
|
|
126
|
+
<li>:url => url: endpoint location e.g. "<a
|
|
127
|
+
href="http://m3pe.org:8080/repositories/test-people">m3pe.org:8080/repositories/test-people</a>"
|
|
128
|
+
|
|
129
|
+
</li>
|
|
130
|
+
<li>:results => one of :xml, :json, :sparql_xml
|
|
131
|
+
|
|
132
|
+
</li>
|
|
133
|
+
</ul>
|
|
134
|
+
</td>
|
|
135
|
+
</tr>
|
|
136
|
+
</table>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
<!-- if method_list -->
|
|
143
|
+
<div id="methods">
|
|
144
|
+
<h3 class="section-bar">Public Class methods</h3>
|
|
145
|
+
|
|
146
|
+
<div id="method-M000001" class="method-detail">
|
|
147
|
+
<a name="M000001"></a>
|
|
148
|
+
|
|
149
|
+
<div class="method-heading">
|
|
150
|
+
<a href="SparqlAdapter.src/M000001.html" target="Code" class="method-signature"
|
|
151
|
+
onclick="popupCode('SparqlAdapter.src/M000001.html');return false;">
|
|
152
|
+
<span class="method-name">new</span><span class="method-args">(params = {})</span>
|
|
153
|
+
</a>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<div class="method-description">
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
|
|
160
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
|
161
|
+
|
|
162
|
+
<div id="method-M000005" class="method-detail">
|
|
163
|
+
<a name="M000005"></a>
|
|
164
|
+
|
|
165
|
+
<div class="method-heading">
|
|
166
|
+
<a href="SparqlAdapter.src/M000005.html" target="Code" class="method-signature"
|
|
167
|
+
onclick="popupCode('SparqlAdapter.src/M000005.html');return false;">
|
|
168
|
+
<span class="method-name">close</span><span class="method-args">()</span>
|
|
169
|
+
</a>
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
<div class="method-description">
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<div id="method-M000004" class="method-detail">
|
|
177
|
+
<a name="M000004"></a>
|
|
178
|
+
|
|
179
|
+
<div class="method-heading">
|
|
180
|
+
<a href="SparqlAdapter.src/M000004.html" target="Code" class="method-signature"
|
|
181
|
+
onclick="popupCode('SparqlAdapter.src/M000004.html');return false;">
|
|
182
|
+
<span class="method-name">execute_sparql_query</span><span class="method-args">(qs, header=nil) {|*clauses| ...}</span>
|
|
183
|
+
</a>
|
|
184
|
+
</div>
|
|
185
|
+
|
|
186
|
+
<div class="method-description">
|
|
187
|
+
<p>
|
|
188
|
+
do the real work of executing the sparql <a
|
|
189
|
+
href="SparqlAdapter.html#M000003">query</a>
|
|
190
|
+
</p>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
|
|
194
|
+
<div id="method-M000003" class="method-detail">
|
|
195
|
+
<a name="M000003"></a>
|
|
196
|
+
|
|
197
|
+
<div class="method-heading">
|
|
198
|
+
<a href="SparqlAdapter.src/M000003.html" target="Code" class="method-signature"
|
|
199
|
+
onclick="popupCode('SparqlAdapter.src/M000003.html');return false;">
|
|
200
|
+
<span class="method-name">query</span><span class="method-args">(query, &block)</span>
|
|
201
|
+
</a>
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
<div class="method-description">
|
|
205
|
+
<p>
|
|
206
|
+
<a href="SparqlAdapter.html#M000003">query</a> datastore with <a
|
|
207
|
+
href="SparqlAdapter.html#M000003">query</a> string (SPARQL), returns array
|
|
208
|
+
with <a href="SparqlAdapter.html#M000003">query</a> results may be called
|
|
209
|
+
with a block
|
|
210
|
+
</p>
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
|
|
214
|
+
<div id="method-M000002" class="method-detail">
|
|
215
|
+
<a name="M000002"></a>
|
|
216
|
+
|
|
217
|
+
<div class="method-heading">
|
|
218
|
+
<a href="SparqlAdapter.src/M000002.html" target="Code" class="method-signature"
|
|
219
|
+
onclick="popupCode('SparqlAdapter.src/M000002.html');return false;">
|
|
220
|
+
<span class="method-name">size</span><span class="method-args">()</span>
|
|
221
|
+
</a>
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
<div class="method-description">
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
</div>
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
</div>
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
<div id="validator-badges">
|
|
236
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
237
|
+
</div>
|
|
238
|
+
|
|
239
|
+
</body>
|
|
240
|
+
</html>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html>
|
|
7
|
+
<head>
|
|
8
|
+
<title>new (SparqlAdapter)</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
+
</head>
|
|
12
|
+
<body class="standalone-code">
|
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/activerdf_sparql/sparql.rb, line 19</span>
|
|
14
|
+
19: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">params</span> = {})
|
|
15
|
+
20: <span class="ruby-ivar">@reads</span> = <span class="ruby-keyword kw">true</span>
|
|
16
|
+
21: <span class="ruby-ivar">@writes</span> = <span class="ruby-keyword kw">false</span>
|
|
17
|
+
22:
|
|
18
|
+
23: <span class="ruby-ivar">@url</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:url</span>] <span class="ruby-operator">||</span> <span class="ruby-value str">''</span>
|
|
19
|
+
24: <span class="ruby-ivar">@result_format</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:results</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">:json</span>
|
|
20
|
+
25: <span class="ruby-ivar">@engine</span> = <span class="ruby-identifier">params</span>[<span class="ruby-identifier">:engine</span>]
|
|
21
|
+
26:
|
|
22
|
+
27: <span class="ruby-identifier">supported_engines</span> = [<span class="ruby-identifier">:yars2</span>, <span class="ruby-identifier">:sesame2</span>, <span class="ruby-identifier">:joseki</span>, <span class="ruby-identifier">:virtuoso</span>]
|
|
23
|
+
28: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ActiveRdfError</span>, <span class="ruby-value str">"SPARQL engine unsupported"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">supported_engines</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-ivar">@engine</span>)
|
|
24
|
+
29:
|
|
25
|
+
30: <span class="ruby-identifier">known_formats</span> = [<span class="ruby-identifier">:xml</span>, <span class="ruby-identifier">:json</span>, <span class="ruby-identifier">:sparql_xml</span>]
|
|
26
|
+
31: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ActiveRdfError</span>, <span class="ruby-value str">"Result format unsupported"</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">known_formats</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-ivar">@result_format</span>)
|
|
27
|
+
32:
|
|
28
|
+
33: <span class="ruby-identifier">$activerdflog</span>.<span class="ruby-identifier">info</span> <span class="ruby-node">"SPARQL adapter initialised #{inspect}"</span>
|
|
29
|
+
34: <span class="ruby-keyword kw">end</span></pre>
|
|
30
|
+
</body>
|
|
31
|
+
</html>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html>
|
|
7
|
+
<head>
|
|
8
|
+
<title>size (SparqlAdapter)</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
+
</head>
|
|
12
|
+
<body class="standalone-code">
|
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/activerdf_sparql/sparql.rb, line 36</span>
|
|
14
|
+
36: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">size</span>
|
|
15
|
+
37: <span class="ruby-identifier">query</span>(<span class="ruby-constant">Query</span>.<span class="ruby-identifier">new</span>.<span class="ruby-identifier">select</span>(<span class="ruby-identifier">:s</span>,<span class="ruby-identifier">:p</span>,<span class="ruby-identifier">:o</span>).<span class="ruby-identifier">where</span>(<span class="ruby-identifier">:s</span>,<span class="ruby-identifier">:p</span>,<span class="ruby-identifier">:o</span>)).<span class="ruby-identifier">size</span>
|
|
16
|
+
38: <span class="ruby-keyword kw">end</span></pre>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html>
|
|
7
|
+
<head>
|
|
8
|
+
<title>query (SparqlAdapter)</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
+
</head>
|
|
12
|
+
<body class="standalone-code">
|
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/activerdf_sparql/sparql.rb, line 42</span>
|
|
14
|
+
42: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">query</span>(<span class="ruby-identifier">query</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
|
15
|
+
43: <span class="ruby-identifier">time</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>
|
|
16
|
+
44: <span class="ruby-identifier">qs</span> = <span class="ruby-constant">Query2SPARQL</span>.<span class="ruby-identifier">translate</span>(<span class="ruby-identifier">query</span>)
|
|
17
|
+
45: <span class="ruby-identifier">execute_sparql_query</span>(<span class="ruby-identifier">qs</span>, <span class="ruby-identifier">header</span>(<span class="ruby-identifier">query</span>), <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
|
18
|
+
46: <span class="ruby-keyword kw">end</span></pre>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html>
|
|
7
|
+
<head>
|
|
8
|
+
<title>execute_sparql_query (SparqlAdapter)</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
+
</head>
|
|
12
|
+
<body class="standalone-code">
|
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/activerdf_sparql/sparql.rb, line 49</span>
|
|
14
|
+
49: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">execute_sparql_query</span>(<span class="ruby-identifier">qs</span>, <span class="ruby-identifier">header</span>=<span class="ruby-keyword kw">nil</span>, <span class="ruby-operator">&</span><span class="ruby-identifier">block</span>)
|
|
15
|
+
50: <span class="ruby-identifier">header</span> = <span class="ruby-identifier">header</span>(<span class="ruby-keyword kw">nil</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">header</span>.<span class="ruby-identifier">nil?</span>
|
|
16
|
+
51:
|
|
17
|
+
52: <span class="ruby-comment cmt"># encoding query string in URL</span>
|
|
18
|
+
53: <span class="ruby-identifier">url</span> = <span class="ruby-node">"#@url?query=#{CGI.escape(qs)}"</span>
|
|
19
|
+
54: <span class="ruby-comment cmt">#url += "&content-type=#{CGI.escape('application/sparql-results+xml')}" if @yars2</span>
|
|
20
|
+
55: <span class="ruby-identifier">url</span> = <span class="ruby-identifier">url</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-value str">"DISTINCT"</span>, <span class="ruby-value str">""</span>) <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@yars2</span>
|
|
21
|
+
56: <span class="ruby-identifier">$activerdflog</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"querying #{url}"</span>
|
|
22
|
+
57:
|
|
23
|
+
58: <span class="ruby-comment cmt"># querying sparql endpoint</span>
|
|
24
|
+
59: <span class="ruby-identifier">response</span> = <span class="ruby-value str">''</span>
|
|
25
|
+
60: <span class="ruby-keyword kw">begin</span>
|
|
26
|
+
61: <span class="ruby-identifier">open</span>(<span class="ruby-identifier">url</span>, <span class="ruby-identifier">header</span>) <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">f</span><span class="ruby-operator">|</span>
|
|
27
|
+
62: <span class="ruby-identifier">response</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">read</span>
|
|
28
|
+
63: <span class="ruby-keyword kw">end</span>
|
|
29
|
+
64: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">OpenURI</span><span class="ruby-operator">::</span><span class="ruby-constant">HTTPError</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">e</span>
|
|
30
|
+
65: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ActiveRdfError</span>, <span class="ruby-node">"could not query SPARQL endpoint, server said: #{e}"</span>
|
|
31
|
+
66: <span class="ruby-keyword kw">return</span> []
|
|
32
|
+
67: <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Errno</span><span class="ruby-operator">::</span><span class="ruby-constant">ECONNREFUSED</span>
|
|
33
|
+
68: <span class="ruby-identifier">raise</span> <span class="ruby-constant">ActiveRdfError</span>, <span class="ruby-value str">"connection refused on SPARQL endpoint #@url"</span>
|
|
34
|
+
69: <span class="ruby-keyword kw">return</span> []
|
|
35
|
+
70: <span class="ruby-keyword kw">end</span>
|
|
36
|
+
71: <span class="ruby-identifier">$activerdflog</span>.<span class="ruby-identifier">debug</span> <span class="ruby-node">"response:\n#{response}"</span>
|
|
37
|
+
72:
|
|
38
|
+
73: <span class="ruby-comment cmt"># we parse content depending on the result format</span>
|
|
39
|
+
74: <span class="ruby-identifier">results</span> = <span class="ruby-keyword kw">case</span> <span class="ruby-ivar">@result_format</span>
|
|
40
|
+
75: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:json</span>
|
|
41
|
+
76: <span class="ruby-identifier">parse_json</span>(<span class="ruby-identifier">response</span>)
|
|
42
|
+
77: <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:xml</span>, <span class="ruby-identifier">:sparql_xml</span>
|
|
43
|
+
78: <span class="ruby-identifier">parse_xml</span>(<span class="ruby-identifier">response</span>)
|
|
44
|
+
79: <span class="ruby-keyword kw">end</span>
|
|
45
|
+
80:
|
|
46
|
+
81: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
|
|
47
|
+
82: <span class="ruby-identifier">results</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-operator">*</span><span class="ruby-identifier">clauses</span><span class="ruby-operator">|</span>
|
|
48
|
+
83: <span class="ruby-keyword kw">yield</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">clauses</span>)
|
|
49
|
+
84: <span class="ruby-keyword kw">end</span>
|
|
50
|
+
85: <span class="ruby-keyword kw">else</span>
|
|
51
|
+
86: <span class="ruby-identifier">results</span>
|
|
52
|
+
87: <span class="ruby-keyword kw">end</span>
|
|
53
|
+
88: <span class="ruby-keyword kw">end</span></pre>
|
|
54
|
+
</body>
|
|
55
|
+
</html>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html>
|
|
7
|
+
<head>
|
|
8
|
+
<title>close (SparqlAdapter)</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
|
11
|
+
</head>
|
|
12
|
+
<body class="standalone-code">
|
|
13
|
+
<pre> <span class="ruby-comment cmt"># File lib/activerdf_sparql/sparql.rb, line 90</span>
|
|
14
|
+
90: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close</span>
|
|
15
|
+
91: <span class="ruby-constant">ConnectionPool</span>.<span class="ruby-identifier">remove_data_source</span>(<span class="ruby-keyword kw">self</span>)
|
|
16
|
+
92: <span class="ruby-keyword kw">end</span></pre>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
+
<!DOCTYPE html
|
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
+
|
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
+
<head>
|
|
8
|
+
<title>Class: SparqlResultParser</title>
|
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
+
<script type="text/javascript">
|
|
13
|
+
// <![CDATA[
|
|
14
|
+
|
|
15
|
+
function popupCode( url ) {
|
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function toggleCode( id ) {
|
|
20
|
+
if ( document.getElementById )
|
|
21
|
+
elem = document.getElementById( id );
|
|
22
|
+
else if ( document.all )
|
|
23
|
+
elem = eval( "document.all." + id );
|
|
24
|
+
else
|
|
25
|
+
return false;
|
|
26
|
+
|
|
27
|
+
elemStyle = elem.style;
|
|
28
|
+
|
|
29
|
+
if ( elemStyle.display != "block" ) {
|
|
30
|
+
elemStyle.display = "block"
|
|
31
|
+
} else {
|
|
32
|
+
elemStyle.display = "none"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Make codeblocks hidden by default
|
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
+
|
|
41
|
+
// ]]>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
<div id="classHeader">
|
|
50
|
+
<table class="header-table">
|
|
51
|
+
<tr class="top-aligned-row">
|
|
52
|
+
<td><strong>Class</strong></td>
|
|
53
|
+
<td class="class-name-in-header">SparqlResultParser</td>
|
|
54
|
+
</tr>
|
|
55
|
+
<tr class="top-aligned-row">
|
|
56
|
+
<td><strong>In:</strong></td>
|
|
57
|
+
<td>
|
|
58
|
+
<a href="../files/lib/activerdf_sparql/sparql_result_parser_rb.html">
|
|
59
|
+
lib/activerdf_sparql/sparql_result_parser.rb
|
|
60
|
+
</a>
|
|
61
|
+
<br />
|
|
62
|
+
</td>
|
|
63
|
+
</tr>
|
|
64
|
+
|
|
65
|
+
<tr class="top-aligned-row">
|
|
66
|
+
<td><strong>Parent:</strong></td>
|
|
67
|
+
<td>
|
|
68
|
+
Object
|
|
69
|
+
</td>
|
|
70
|
+
</tr>
|
|
71
|
+
</table>
|
|
72
|
+
</div>
|
|
73
|
+
<!-- banner header -->
|
|
74
|
+
|
|
75
|
+
<div id="bodyContent">
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
<div id="contextContent">
|
|
80
|
+
|
|
81
|
+
<div id="description">
|
|
82
|
+
<p>
|
|
83
|
+
Parser for SPARQL XML result set.
|
|
84
|
+
</p>
|
|
85
|
+
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
</div>
|
|
90
|
+
|
|
91
|
+
<div id="method-list">
|
|
92
|
+
<h3 class="section-bar">Methods</h3>
|
|
93
|
+
|
|
94
|
+
<div class="name-list">
|
|
95
|
+
<a href="#M000010">create_node</a>
|
|
96
|
+
<a href="#M000011">method_missing</a>
|
|
97
|
+
<a href="#M000006">new</a>
|
|
98
|
+
<a href="#M000008">tag_end</a>
|
|
99
|
+
<a href="#M000007">tag_start</a>
|
|
100
|
+
<a href="#M000009">text</a>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
</div>
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
<!-- if includes -->
|
|
108
|
+
|
|
109
|
+
<div id="section">
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
<div id="attribute-list">
|
|
116
|
+
<h3 class="section-bar">Attributes</h3>
|
|
117
|
+
|
|
118
|
+
<div class="name-list">
|
|
119
|
+
<table>
|
|
120
|
+
<tr class="top-aligned-row context-row">
|
|
121
|
+
<td class="context-item-name">result</td>
|
|
122
|
+
<td class="context-item-value"> [R] </td>
|
|
123
|
+
<td class="context-item-desc"></td>
|
|
124
|
+
</tr>
|
|
125
|
+
</table>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
<!-- if method_list -->
|
|
132
|
+
<div id="methods">
|
|
133
|
+
<h3 class="section-bar">Public Class methods</h3>
|
|
134
|
+
|
|
135
|
+
<div id="method-M000006" class="method-detail">
|
|
136
|
+
<a name="M000006"></a>
|
|
137
|
+
|
|
138
|
+
<div class="method-heading">
|
|
139
|
+
<a href="SparqlResultParser.src/M000006.html" target="Code" class="method-signature"
|
|
140
|
+
onclick="popupCode('SparqlResultParser.src/M000006.html');return false;">
|
|
141
|
+
<span class="method-name">new</span><span class="method-args">()</span>
|
|
142
|
+
</a>
|
|
143
|
+
</div>
|
|
144
|
+
|
|
145
|
+
<div class="method-description">
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
|
|
149
|
+
<h3 class="section-bar">Public Instance methods</h3>
|
|
150
|
+
|
|
151
|
+
<div id="method-M000010" class="method-detail">
|
|
152
|
+
<a name="M000010"></a>
|
|
153
|
+
|
|
154
|
+
<div class="method-heading">
|
|
155
|
+
<a href="SparqlResultParser.src/M000010.html" target="Code" class="method-signature"
|
|
156
|
+
onclick="popupCode('SparqlResultParser.src/M000010.html');return false;">
|
|
157
|
+
<span class="method-name">create_node</span><span class="method-args">(type, value)</span>
|
|
158
|
+
</a>
|
|
159
|
+
</div>
|
|
160
|
+
|
|
161
|
+
<div class="method-description">
|
|
162
|
+
<p>
|
|
163
|
+
create ruby objects for each RDF node
|
|
164
|
+
</p>
|
|
165
|
+
</div>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
<div id="method-M000011" class="method-detail">
|
|
169
|
+
<a name="M000011"></a>
|
|
170
|
+
|
|
171
|
+
<div class="method-heading">
|
|
172
|
+
<a href="SparqlResultParser.src/M000011.html" target="Code" class="method-signature"
|
|
173
|
+
onclick="popupCode('SparqlResultParser.src/M000011.html');return false;">
|
|
174
|
+
<span class="method-name">method_missing</span><span class="method-args">(*args)</span>
|
|
175
|
+
</a>
|
|
176
|
+
</div>
|
|
177
|
+
|
|
178
|
+
<div class="method-description">
|
|
179
|
+
</div>
|
|
180
|
+
</div>
|
|
181
|
+
|
|
182
|
+
<div id="method-M000008" class="method-detail">
|
|
183
|
+
<a name="M000008"></a>
|
|
184
|
+
|
|
185
|
+
<div class="method-heading">
|
|
186
|
+
<a href="SparqlResultParser.src/M000008.html" target="Code" class="method-signature"
|
|
187
|
+
onclick="popupCode('SparqlResultParser.src/M000008.html');return false;">
|
|
188
|
+
<span class="method-name">tag_end</span><span class="method-args">(name)</span>
|
|
189
|
+
</a>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<div class="method-description">
|
|
193
|
+
</div>
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
<div id="method-M000007" class="method-detail">
|
|
197
|
+
<a name="M000007"></a>
|
|
198
|
+
|
|
199
|
+
<div class="method-heading">
|
|
200
|
+
<a href="SparqlResultParser.src/M000007.html" target="Code" class="method-signature"
|
|
201
|
+
onclick="popupCode('SparqlResultParser.src/M000007.html');return false;">
|
|
202
|
+
<span class="method-name">tag_start</span><span class="method-args">(name, attrs)</span>
|
|
203
|
+
</a>
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
<div class="method-description">
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
|
|
210
|
+
<div id="method-M000009" class="method-detail">
|
|
211
|
+
<a name="M000009"></a>
|
|
212
|
+
|
|
213
|
+
<div class="method-heading">
|
|
214
|
+
<a href="SparqlResultParser.src/M000009.html" target="Code" class="method-signature"
|
|
215
|
+
onclick="popupCode('SparqlResultParser.src/M000009.html');return false;">
|
|
216
|
+
<span class="method-name">text</span><span class="method-args">(text)</span>
|
|
217
|
+
</a>
|
|
218
|
+
</div>
|
|
219
|
+
|
|
220
|
+
<div class="method-description">
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
</div>
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
<div id="validator-badges">
|
|
232
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
</body>
|
|
236
|
+
</html>
|