annotate jamendo/sparql-archived/SeRQL/serql.html @ 27:d95e683fbd35 tip

Enable CORS on urispace redirects as well
author Chris Cannam
date Tue, 20 Feb 2018 14:52:02 +0000
parents df9685986338
children
rev   line source
Chris@0 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Chris@0 2
Chris@0 3 <HTML>
Chris@0 4 <HEAD>
Chris@0 5 <TITLE>SWI-Prolog Semantic Web Server</TITLE><STYLE type="text/css">
Chris@0 6 /* Style sheet for SWI-Prolog latex2html
Chris@0 7 */
Chris@0 8
Chris@0 9 dd.defbody
Chris@0 10 { margin-bottom: 1em;
Chris@0 11 }
Chris@0 12
Chris@0 13 dt.pubdef
Chris@0 14 { background-color: #c5e1ff;
Chris@0 15 }
Chris@0 16
Chris@0 17 pre.code
Chris@0 18 { margin-left: 1.5em;
Chris@0 19 margin-right: 1.5em;
Chris@0 20 border: 1px dotted;
Chris@0 21 padding-top: 5px;
Chris@0 22 padding-left: 5px;
Chris@0 23 padding-bottom: 5px;
Chris@0 24 background-color: #f8f8f8;
Chris@0 25 }
Chris@0 26
Chris@0 27 div.navigate
Chris@0 28 { text-align: center;
Chris@0 29 background-color: #f0f0f0;
Chris@0 30 border: 1px dotted;
Chris@0 31 padding: 5px;
Chris@0 32 }
Chris@0 33
Chris@0 34 div.title
Chris@0 35 { text-align: center;
Chris@0 36 padding-bottom: 1em;
Chris@0 37 font-size: 200%;
Chris@0 38 font-weight: bold;
Chris@0 39 }
Chris@0 40
Chris@0 41 div.author
Chris@0 42 { text-align: center;
Chris@0 43 font-style: italic;
Chris@0 44 }
Chris@0 45
Chris@0 46 div.abstract
Chris@0 47 { margin-top: 2em;
Chris@0 48 background-color: #f0f0f0;
Chris@0 49 border: 1px dotted;
Chris@0 50 padding: 5px;
Chris@0 51 margin-left: 10%; margin-right:10%;
Chris@0 52 }
Chris@0 53
Chris@0 54 div.abstract-title
Chris@0 55 { text-align: center;
Chris@0 56 padding: 5px;
Chris@0 57 font-size: 120%;
Chris@0 58 font-weight: bold;
Chris@0 59 }
Chris@0 60
Chris@0 61 div.toc-h1
Chris@0 62 { font-size: 200%;
Chris@0 63 font-weight: bold;
Chris@0 64 }
Chris@0 65
Chris@0 66 div.toc-h2
Chris@0 67 { font-size: 120%;
Chris@0 68 font-weight: bold;
Chris@0 69 margin-left: 2em;
Chris@0 70 }
Chris@0 71
Chris@0 72 div.toc-h3
Chris@0 73 { font-size: 100%;
Chris@0 74 font-weight: bold;
Chris@0 75 margin-left: 4em;
Chris@0 76 }
Chris@0 77
Chris@0 78 div.toc-h4
Chris@0 79 { font-size: 100%;
Chris@0 80 margin-left: 6em;
Chris@0 81 }
Chris@0 82
Chris@0 83 span.sec-nr
Chris@0 84 {
Chris@0 85 }
Chris@0 86
Chris@0 87 span.sec-title
Chris@0 88 { margin-left: 0.5em;
Chris@0 89 }
Chris@0 90
Chris@0 91 span.pred-ext
Chris@0 92 { font-weight: bold;
Chris@0 93 }
Chris@0 94
Chris@0 95 /* Footnotes */
Chris@0 96
Chris@0 97 sup.fn { color: blue; text-decoration: underline; }
Chris@0 98 span.fn-text: { display: none; }
Chris@0 99 sup.fn span {display: none;}
Chris@0 100 sup:hover span
Chris@0 101 { display: block !important;
Chris@0 102 position: absolute; top: auto; left: auto; width: 80%;
Chris@0 103 color: #000; background: white;
Chris@0 104 border: 2px solid;
Chris@0 105 padding: 5px; margin: 10px; z-index: 100;
Chris@0 106 font-size: smaller;
Chris@0 107 }
Chris@0 108 </STYLE>
Chris@0 109 </HEAD>
Chris@0 110 <BODY BGCOLOR="white">
Chris@0 111
Chris@0 112 <P>
Chris@0 113 <DIV class="title">SWI-Prolog Semantic Web Server</DIV>
Chris@0 114 <DIV class="author">Jan Wielemaker <BR>
Chris@0 115 Human Computer Studies (HCS), <BR>
Chris@0 116 University of Amsterdam <BR>
Chris@0 117 The Netherlands <BR>
Chris@0 118 E-mail: <A class="url" href="mailto:wielemak@science.uva.nl">wielemak@science.uva.nl</A></DIV>
Chris@0 119 <DIV class="abstract">
Chris@0 120 <DIV class="abstract-title">Abstract</DIV> SWI-Prolog offers an
Chris@0 121 extensive library for loading, saving and querying Semantic Web
Chris@0 122 documents. Internally, the query language is `Prolog', building on top
Chris@0 123 of an efficient implementation of a predicate <A NAME="idx:rdf3:1"></A><SPAN class="pred-ext">rdf/3</SPAN>
Chris@0 124 expressing the content of the triple store.
Chris@0 125
Chris@0 126 <P>Emerging dedicated Semantic Web query languages change this view.
Chris@0 127 Supporting such languages provides a comfortable infrastructure for
Chris@0 128 distributed Semantic Web processing systems. This document describes the
Chris@0 129 SWI-Prolog Semantic Web Server. The server provides access to the Prolog
Chris@0 130 triple store using either SeRQL or SPARQL. At the same time it is an
Chris@0 131 extensible platform for realising Semantic Web based applications.
Chris@0 132 </DIV>
Chris@0 133
Chris@0 134 <H1><A NAME="document-contents">Table of Contents</A></H1>
Chris@0 135
Chris@0 136 <DIV class="toc">
Chris@0 137 <DIV class="toc-h2"><A class="sec" href="#sec:1"><SPAN class="sec-nr">1</SPAN><SPAN class="sec-title">Introduction</SPAN></A></DIV>
Chris@0 138 <DIV class="toc-h2"><A class="sec" href="#sec:2"><SPAN class="sec-nr">2</SPAN><SPAN class="sec-title">Query
Chris@0 139 Languages</SPAN></A></DIV>
Chris@0 140 <DIV class="toc-h3"><A class="sec" href="#sec:2.1"><SPAN class="sec-nr">2.1</SPAN><SPAN class="sec-title">SPARQL
Chris@0 141 Support</SPAN></A></DIV>
Chris@0 142 <DIV class="toc-h3"><A class="sec" href="#sec:2.2"><SPAN class="sec-nr">2.2</SPAN><SPAN class="sec-title">SeRQL
Chris@0 143 Support</SPAN></A></DIV>
Chris@0 144 <DIV class="toc-h2"><A class="sec" href="#sec:3"><SPAN class="sec-nr">3</SPAN><SPAN class="sec-title">Installation
Chris@0 145 and Administration</SPAN></A></DIV>
Chris@0 146 <DIV class="toc-h3"><A class="sec" href="#sec:3.1"><SPAN class="sec-nr">3.1</SPAN><SPAN class="sec-title">Getting
Chris@0 147 started</SPAN></A></DIV>
Chris@0 148 <DIV class="toc-h3"><A class="sec" href="#sec:3.2"><SPAN class="sec-nr">3.2</SPAN><SPAN class="sec-title">Persistent
Chris@0 149 store</SPAN></A></DIV>
Chris@0 150 <DIV class="toc-h2"><A class="sec" href="#sec:4"><SPAN class="sec-nr">4</SPAN><SPAN class="sec-title">Roadmap</SPAN></A></DIV>
Chris@0 151 <DIV class="toc-h3"><A class="sec" href="#sec:4.1"><SPAN class="sec-nr">4.1</SPAN><SPAN class="sec-title">Query
Chris@0 152 processing and entailment</SPAN></A></DIV>
Chris@0 153 <DIV class="toc-h3"><A class="sec" href="#sec:4.2"><SPAN class="sec-nr">4.2</SPAN><SPAN class="sec-title">Query
Chris@0 154 optimisation</SPAN></A></DIV>
Chris@0 155 <DIV class="toc-h3"><A class="sec" href="#sec:4.3"><SPAN class="sec-nr">4.3</SPAN><SPAN class="sec-title">Webserver</SPAN></A></DIV>
Chris@0 156 <DIV class="toc-h2"><A class="sec" href="#sec:5"><SPAN class="sec-nr">5</SPAN><SPAN class="sec-title">The
Chris@0 157 Sesame client</SPAN></A></DIV>
Chris@0 158 <DIV class="toc-h2"><A class="sec" href="#sec:6"><SPAN class="sec-nr">6</SPAN><SPAN class="sec-title">Sesame
Chris@0 159 interoperability</SPAN></A></DIV>
Chris@0 160 <DIV class="toc-h2"><A class="sec" href="#sec:7"><SPAN class="sec-nr">7</SPAN><SPAN class="sec-title">The
Chris@0 161 SPARQL client</SPAN></A></DIV>
Chris@0 162 <DIV class="toc-h2"><A class="sec" href="#sec:8"><SPAN class="sec-nr">8</SPAN><SPAN class="sec-title">Security
Chris@0 163 issues</SPAN></A></DIV>
Chris@0 164 <DIV class="toc-h2"><A class="sec" href="#sec:9"><SPAN class="sec-nr">9</SPAN><SPAN class="sec-title">Downloading</SPAN></A></DIV>
Chris@0 165 </DIV>
Chris@0 166
Chris@0 167 <P>
Chris@0 168
Chris@0 169 <H2><A NAME="sec:1"><SPAN class="sec-nr">1</SPAN><SPAN class="sec-title">Introduction</SPAN></A></H2>
Chris@0 170
Chris@0 171 <P>The SWI-Prolog Semantic Web Server unifies the SWI-Prolog general Web
Chris@0 172 support and Semantic Web support, providing both a starting point for
Chris@0 173 dedicated applications and a platform for exchange of RDF-based data
Chris@0 174 using a standardised language and protocol. An overview of the
Chris@0 175 SWI-Prolog Web support libraries can be found in <A class="url" href="http://hcs.science.uva.nl/projects/SWI-Prolog/articles/TPLP-plweb.pdf">SWI-Prolog
Chris@0 176 and the Web</A>,<SUP class="fn">1<SPAN class="fn-text">Submitted to
Chris@0 177 Theory and Practice of Logic Programming</SPAN></SUP>
Chris@0 178
Chris@0 179 <H2><A NAME="sec:2"><SPAN class="sec-nr">2</SPAN><SPAN class="sec-title">Query
Chris@0 180 Languages</SPAN></A></H2>
Chris@0 181
Chris@0 182 <P>The current server supports two query languages:
Chris@0 183 <A class="url" href="http://www.openrdf.org">SeRQL</A> and
Chris@0 184 <A class="url" href="http://www.w3.org/TR/rdf-sparql-query/">SPARQL</A>.
Chris@0 185 For both languages we provide an interactive service that presents the
Chris@0 186 results as a human-readable HTML table, a service presenting its result
Chris@0 187 as RDF/XML or XML that follows the HTTP protocol definition for the
Chris@0 188 query language, the possibility to query the local database using a
Chris@0 189 query language in Prolog and a Prolog client that can be used to query
Chris@0 190 remote services supporting the query language and HTTP service.
Chris@0 191
Chris@0 192 <P>For both query languages, queries are translated to a complex Prolog
Chris@0 193 goal calling <A NAME="idx:rdf3:2"></A><SPAN class="pred-ext">rdf/3</SPAN>
Chris@0 194 to resolve edges in the graph and calls to predicates from
Chris@0 195 rdfql_runtime.pl that realise constraints imposed by the SeRQL
Chris@0 196 <CODE>WHERE</CODE> clause and SPARQL <CODE>FILTER</CODE> clauses.
Chris@0 197
Chris@0 198 <H3><A NAME="sec:2.1"><SPAN class="sec-nr">2.1</SPAN><SPAN class="sec-title">SPARQL
Chris@0 199 Support</SPAN></A></H3>
Chris@0 200
Chris@0 201 <P>SPARQL support is based on the SPARQL specification, versioned April
Chris@0 202 6, 2006. Status:
Chris@0 203
Chris@0 204 <P><UL COMPACT>
Chris@0 205 <LI>No query optimization
Chris@0 206 <LI>Limited value-testing, notably on xsd:dateTime
Chris@0 207 <LI>Incomplete ORDER BY support. Only ascending and all values are
Chris@0 208 compared lexically.
Chris@0 209 <LI>No support for named graphs
Chris@0 210 <LI>Passes current test-suite, except tests affected by the above or
Chris@0 211 acknowledged as errornous.
Chris@0 212 </UL>
Chris@0 213
Chris@0 214 <H3><A NAME="sec:2.2"><SPAN class="sec-nr">2.2</SPAN><SPAN class="sec-title">SeRQL
Chris@0 215 Support</SPAN></A></H3>
Chris@0 216
Chris@0 217 <P>SeRQL support and compatibility is based on development version
Chris@0 218 20040820, with additional support for the new 1.2 syntax and some of the
Chris@0 219 built-in functions. Both SeRQL and the HTTP API are fully defined in the
Chris@0 220 Sesame documentation.
Chris@0 221
Chris@0 222 <H2><A NAME="sec:3"><SPAN class="sec-nr">3</SPAN><SPAN class="sec-title">Installation
Chris@0 223 and Administration</SPAN></A></H2>
Chris@0 224
Chris@0 225 <H3><A NAME="sec:3.1"><SPAN class="sec-nr">3.1</SPAN><SPAN class="sec-title">Getting
Chris@0 226 started</SPAN></A></H3>
Chris@0 227
Chris@0 228 <P>The file <CODE>parms.pl</CODE> contains a number of settings relevant
Chris@0 229 to the server. Notable the port to connect to, where to store user
Chris@0 230 information, etc. Persistent data kept by the server is a list of users
Chris@0 231 and their access rights (default <CODE>users.db</CODE>) and a file-based
Chris@0 232 backup of the in-memory store (default in the directory <CODE>SeRQL-store</CODE>).
Chris@0 233 Please check the content of <CODE>parms.pl</CODE> and follow directions
Chris@0 234 in the comments. On Unix-like systems, edit <CODE>run.pl</CODE> to
Chris@0 235 adjust the location of SWI-Prolog on the <CODE>!#</CODE> line. Next,
Chris@0 236 start <CODE>run.pl</CODE> and launch the server using the command below.
Chris@0 237
Chris@0 238 <PRE class="code">
Chris@0 239 ?- serql_server.
Chris@0 240 </PRE>
Chris@0 241
Chris@0 242 <P>Now direct your browser to the server, using the default setup this
Chris@0 243 is <A class="url" href="http://localhost:3020">http://localhost:3020</A>.
Chris@0 244 If no users are defined the browser will prompt to enter the
Chris@0 245 administrative password. After that the admin and anonymous users are
Chris@0 246 created. Accounts can be created and modified by users with
Chris@0 247 administrative rights through the
Chris@0 248 <EM>List users ...</EM> link on the sidebar.
Chris@0 249
Chris@0 250 <P>To restart from scratch, stop the server, delete the users database
Chris@0 251 file and/or the triple backup file and restart the server as described
Chris@0 252 above.
Chris@0 253
Chris@0 254 <H3><A NAME="sec:3.2"><SPAN class="sec-nr">3.2</SPAN><SPAN class="sec-title">Persistent
Chris@0 255 store</SPAN></A></H3>
Chris@0 256
Chris@0 257 <A NAME="sec:backup"></A>
Chris@0 258
Chris@0 259 <P>The <CODE>parms.pl</CODE> setting <CODE>persistent_store(Directory,
Chris@0 260 Options)</CODE> can be used to specify file-based persistent backup for
Chris@0 261 the in-memory triple store. The store is a combination of quick-load
Chris@0 262 triple databases and journal files that hold the modifications made to
Chris@0 263 the triple store. Details of the persistent store are documented with
Chris@0 264 the SWI-Prolog
Chris@0 265 <A class="url" href="http://www.swi-prolog.org/packages/semweb.html">Semantic
Chris@0 266 Web package</A>
Chris@0 267
Chris@0 268 <H2><A NAME="sec:4"><SPAN class="sec-nr">4</SPAN><SPAN class="sec-title">Roadmap</SPAN></A></H2>
Chris@0 269
Chris@0 270 <H3><A NAME="sec:4.1"><SPAN class="sec-nr">4.1</SPAN><SPAN class="sec-title">Query
Chris@0 271 processing and entailment</SPAN></A></H3>
Chris@0 272
Chris@0 273 <A NAME="sec:entailment"></A>
Chris@0 274
Chris@0 275 <P>The kernel of the system is formed by <CODE>serql.pl</CODE> and <CODE>sparql</CODE>,
Chris@0 276 that implement the DCG parsers for the respective query languages as
Chris@0 277 well as a compiler that translates this into a Prolog goal executing the
Chris@0 278 query op top of the SWI-Prolog SemWeb package. The file
Chris@0 279 <CODE>rdfql_runtime.pl</CODE> contains predicates that implement the
Chris@0 280 constraints (SeRQL WHERE or SPARQL FILTER) and other constructs
Chris@0 281 generated by the query-compiler.
Chris@0 282
Chris@0 283 <P>Entailment reasoning is defined by <CODE>rdf_entailment.pl</CODE>.
Chris@0 284 Specific entailments are in seperate files:
Chris@0 285
Chris@0 286 <DL>
Chris@0 287 <DT><B><CODE>no_entailment.pl</CODE></B></DT>
Chris@0 288 <DD>
Chris@0 289 Defines entailment <CODE>none</CODE>. Query explicitely stored triples
Chris@0 290 only.</DD>
Chris@0 291 <DT><B><CODE>rdf_entailment.pl</CODE></B></DT>
Chris@0 292 <DD>
Chris@0 293 Defines entailment <CODE>rdf</CODE>. Any resource appearing in a
Chris@0 294 predicate position is of type <CODE>rdf:Property</CODE>. Any subject is
Chris@0 295 an instance of <CODE>rdf:Resource</CODE></DD>
Chris@0 296 <DT><B><CODE>rdfs_entailment.pl</CODE></B></DT>
Chris@0 297 <DD>
Chris@0 298 Defines entailment <CODE>rdfs</CODE>. Adds class- and property-hierarchy
Chris@0 299 reasoning to RDF reasoning, as well as reasoning on the basis of
Chris@0 300 property domain and range.</DD>
Chris@0 301 <DT><B><CODE>rdfslite_entailment.pl</CODE></B></DT>
Chris@0 302 <DD>
Chris@0 303 Defines entailment <CODE>rdfslite</CODE>. Only considers the class- and
Chris@0 304 property-hierarchy. Using a backward chaining solver this is much
Chris@0 305 faster, while normally keeping the intended meaning.
Chris@0 306 </DD>
Chris@0 307 </DL>
Chris@0 308
Chris@0 309 <P>The query compiler and execution system can be called directly from
Chris@0 310 Prolog.
Chris@0 311
Chris@0 312 <DL>
Chris@0 313 <DT class="pubdef"><A NAME="serql_compile/3"><STRONG>serql_compile</STRONG>(<VAR>+Query,
Chris@0 314 -Compiled, +Options</VAR>)</A></DT>
Chris@0 315 <DD class="defbody">
Chris@0 316 Compile <VAR>Query</VAR>, which is either an atom or a list of character
Chris@0 317 codes and unify <VAR>Compiled</VAR> with an opaque term representing the
Chris@0 318 query and suitable for passing to <A NAME="idx:serqlrun2:3"></A><A class="pred" href="#serql_run/2">serql_run/2</A>.
Chris@0 319 Defined
Chris@0 320 <VAR>Options</VAR> are:
Chris@0 321
Chris@0 322 <DL>
Chris@0 323 <DT><STRONG>entailment</STRONG>(<VAR>Entailment</VAR>)</DT>
Chris@0 324 <DD class="defbody">
Chris@0 325 Entailment to use. Default is <CODE>rdfs</CODE>. See <A class="sec" href="#sec:4.1">section
Chris@0 326 4.1</A>.</DD>
Chris@0 327 <DT><STRONG>type</STRONG>(<VAR>-Type</VAR>)</DT>
Chris@0 328 <DD class="defbody">
Chris@0 329 Extract the type of query compiled and generally useful information on
Chris@0 330 it. SeRQL defines the types <CODE>construct</CODE> and
Chris@0 331 <CODE>select(VarNames)</CODE>, where <VAR>VarNames</VAR> is a list of
Chris@0 332 variables appearing in the projection.</DD>
Chris@0 333 <DT><STRONG>optimise</STRONG>(<VAR>Bool</VAR>)</DT>
Chris@0 334 <DD class="defbody">
Chris@0 335 Whether or not to optimise the query. Default is defined by the setting
Chris@0 336 <CODE>optimise_query</CODE>.
Chris@0 337 </DD>
Chris@0 338 </DL>
Chris@0 339
Chris@0 340 </DD>
Chris@0 341 <DT class="pubdef"><A NAME="sparql_compile/3"><STRONG>sparql_compile</STRONG>(<VAR>+Query,
Chris@0 342 -Compiled, +Options</VAR>)</A></DT>
Chris@0 343 <DD class="defbody">
Chris@0 344 Similar to to <A NAME="idx:serqlcompile3:4"></A><A class="pred" href="#serql_compile/3">serql_compile/3</A>.
Chris@0 345 Defined types are extended with
Chris@0 346 <CODE>describe</CODE> and <CODE>ask</CODE>. Addional options are:
Chris@0 347
Chris@0 348 <DL>
Chris@0 349 <DT><STRONG>base_uri</STRONG>(<VAR>-URI</VAR>)</DT>
Chris@0 350 <DD class="defbody">
Chris@0 351 Base URI used to compile the query if not specified as part of the
Chris@0 352 query.</DD>
Chris@0 353 <DT><STRONG>ordered</STRONG>(<VAR>-Bool</VAR>)</DT>
Chris@0 354 <DD class="defbody">
Chris@0 355 Unify <VAR>Bool</VAR> with true if query contains an <CODE>ORDER BY</CODE>
Chris@0 356 clause.</DD>
Chris@0 357 <DT><STRONG>distinct</STRONG>(<VAR>-Bool</VAR>)</DT>
Chris@0 358 <DD class="defbody">
Chris@0 359 Unify <VAR>Bool</VAR> with true if query contains a <CODE>DISTINCT</CODE>
Chris@0 360 modifier.
Chris@0 361 </DD>
Chris@0 362 </DL>
Chris@0 363
Chris@0 364 </DD>
Chris@0 365 <DT class="pubdef"><A NAME="serql_run/2"><STRONG>serql_run</STRONG>(<VAR>+Compiled,
Chris@0 366 -Answer</VAR>)</A></DT>
Chris@0 367 <DD class="defbody">
Chris@0 368 Run a query compiled by <A NAME="idx:serqlcompile3:5"></A><A class="pred" href="#serql_compile/3">serql_compile/3</A>,
Chris@0 369 returning terms <CODE>row(Arg ...)</CODE> for select queries and terms <CODE>rdf(Subject,
Chris@0 370 Predicate, Object)</CODE> for construct queries. Subsequent results are
Chris@0 371 returned on backtracking.</DD>
Chris@0 372 <DT class="pubdef"><A NAME="sparql_run/2"><STRONG>sparql_run</STRONG>(<VAR>+Compiled,
Chris@0 373 -Answer</VAR>)</A></DT>
Chris@0 374 <DD class="defbody">
Chris@0 375 Similar to <A NAME="idx:serqlrun2:6"></A><A class="pred" href="#serql_run/2">serql_run/2</A>.
Chris@0 376 Queries of type <CODE>describe</CODE> return rdf-terms like <CODE>construct</CODE>.
Chris@0 377 Queries of type <CODE>ask</CODE> return either <CODE>true</CODE> or <CODE>false</CODE>.</DD>
Chris@0 378 <DT class="pubdef"><A NAME="serql_query/3"><STRONG>serql_query</STRONG>(<VAR>+Query,
Chris@0 379 -Answer, +Options</VAR>)</A></DT>
Chris@0 380 <DD class="defbody">
Chris@0 381 Utility combining of <A NAME="idx:serqlcompile3:7"></A><A class="pred" href="#serql_compile/3">serql_compile/3</A>
Chris@0 382 and <A NAME="idx:serqlrun2:8"></A><A class="pred" href="#serql_run/2">serql_run/2</A>.
Chris@0 383 Note this gives no access to the column-names.</DD>
Chris@0 384 <DT class="pubdef"><A NAME="sparql_query/3"><STRONG>sparql_query</STRONG>(<VAR>+Query,
Chris@0 385 -Answer, +Options</VAR>)</A></DT>
Chris@0 386 <DD class="defbody">
Chris@0 387 Similar to <A NAME="idx:serqlquery3:9"></A><A class="pred" href="#serql_query/3">serql_query/3</A>.
Chris@0 388 </DD>
Chris@0 389 </DL>
Chris@0 390
Chris@0 391 <H3><A NAME="sec:4.2"><SPAN class="sec-nr">4.2</SPAN><SPAN class="sec-title">Query
Chris@0 392 optimisation</SPAN></A></H3>
Chris@0 393
Chris@0 394 <P>By default, but under control of the <A NAME="idx:setting1:10"></A><SPAN class="pred-ext">setting/1</SPAN>
Chris@0 395 option
Chris@0 396 <CODE>optimise_query(Bool)</CODE>, and the option <CODE>optimise(Bool)</CODE>,
Chris@0 397 the query compiler optimises initial goal obtained from naive
Chris@0 398 translation of the query text. The optimiser is defined in <CODE>rdf_optimise.pl</CODE>.
Chris@0 399 The optimiser is described in detail in <A class="url" href="http://hcs.science.uva.nl/projects/SWI-Prolog/articles/ICLP05-SeRQL.pdf">An
Chris@0 400 optimised Semantic Web query language implementation in Prolog</A>. The
Chris@0 401 optimiser reorders goals in the generated conjunction and prepares for
Chris@0 402 independent execution of independent parts of the generated goal. With
Chris@0 403 the optimiser enabled (default), the provided order of path-expressions
Chris@0 404 on the query text is completely ignored and constraints are inserted at
Chris@0 405 the earliest possible point.
Chris@0 406
Chris@0 407 <P>The SeRQL <CODE>LIKE</CODE> operator applies to both resources and
Chris@0 408 literals, while the SWI-Prolog RDF-DB module can only handle <CODE>LIKE</CODE>
Chris@0 409 efficiently on literals. The optimiser can be made aware of this using
Chris@0 410 <CODE>WHERE label(X) LIKE "joe*"</CODE>. Taking the label informs the
Chris@0 411 optimiser that it only needs to consider literals. Likewise, equivalence
Chris@0 412 tests where one of the arguments is used as subject or predicate or has
Chris@0 413 the isResource(X) constraint tell the system it can do straight
Chris@0 414 identifier comparison rather then the much more expensive general
Chris@0 415 comparison.
Chris@0 416
Chris@0 417 <P>Query optimisation is not yet supported for SPARQL.
Chris@0 418
Chris@0 419 <H3><A NAME="sec:4.3"><SPAN class="sec-nr">4.3</SPAN><SPAN class="sec-title">Webserver</SPAN></A></H3>
Chris@0 420
Chris@0 421 <P>The webserver is realised by <CODE>server.pl</CODE>, merely loading
Chris@0 422 both components: <CODE>http_data.pl</CODE> providing the Sesame HTTP API
Chris@0 423 using the same paths and parameters and <CODE>http_user.pl</CODE>
Chris@0 424 providing a browser-friendly frontend. Error messages are still very
Chris@0 425 crude and almost all errors return a 500 server error page with a
Chris@0 426 transcription of the Prolog exception.
Chris@0 427
Chris@0 428 <P>The Sesame HTTP API deals with a large number of data formats, only
Chris@0 429 part of which are realised by the current system. This realisation is
Chris@0 430 achieved through <CODE>rdf_result</CODE>, providing an extensible API
Chris@0 431 for reading and writing in different formats. <CODE>rdf_html</CODE>,
Chris@0 432 <CODE>rdf_write</CODE> and <CODE>xml_result</CODE> provide some
Chris@0 433 implementations thereof.
Chris@0 434
Chris@0 435 <H2><A NAME="sec:5"><SPAN class="sec-nr">5</SPAN><SPAN class="sec-title">The
Chris@0 436 Sesame client</SPAN></A></H2>
Chris@0 437
Chris@0 438 <P>The file <CODE>sesame_client.pl</CODE>, created by <A class="url" href="mailto:mrmenken@cs.vu.nl">Maarten
Chris@0 439 Menken</A> provides an API to remote Sesame servers. Below is a brief
Chris@0 440 documentation of the available primitives. All predicates take an option
Chris@0 441 list. To simplify applications that communicate with a single server
Chris@0 442 defauls for the server and reposititory locations can be specified using
Chris@0 443 <A NAME="idx:setsesamedefault1:11"></A><A class="pred" href="#set_sesame_default/1">set_sesame_default/1</A>.
Chris@0 444
Chris@0 445 <DL>
Chris@0 446 <DT class="pubdef"><A NAME="set_sesame_default/1"><STRONG>set_sesame_default</STRONG>(<VAR>+DefaultOrList</VAR>)</A></DT>
Chris@0 447 <DD class="defbody">
Chris@0 448 This predicate can be used to specify defaults for the options available
Chris@0 449 to the other Sesame interface predicates. A default is a term <CODE>Option(Value)</CODE>.
Chris@0 450 If a list of such options is provided all options are set in the order
Chris@0 451 of appearance in the list. This implies options later in the list may
Chris@0 452 overrule already set options. Defined options are:
Chris@0 453
Chris@0 454 <DL>
Chris@0 455 <DT><STRONG>host</STRONG>(<VAR>Host</VAR>)</DT>
Chris@0 456 <DD class="defbody">
Chris@0 457 Hostname running the Sesame server.
Chris@0 458 </DD>
Chris@0 459 <DT><STRONG>port</STRONG>(<VAR>Port</VAR>)</DT>
Chris@0 460 <DD class="defbody">
Chris@0 461 Por the sesame server listens on.
Chris@0 462 </DD>
Chris@0 463 <DT><STRONG>path</STRONG>(<VAR>Path</VAR>)</DT>
Chris@0 464 <DD class="defbody">
Chris@0 465 Path from the root to the Sesame server. For the SWI-Prolog Sesame
Chris@0 466 client, this is normally the empty atom (<CODE>''</CODE>). For thte Java
Chris@0 467 based Sesame this is normally <CODE>'/sesame'</CODE>.
Chris@0 468 </DD>
Chris@0 469 <DT><STRONG>repository</STRONG>(<VAR>Repository</VAR>)</DT>
Chris@0 470 <DD class="defbody">
Chris@0 471 Name of the repository to connect to. See also
Chris@0 472 <A NAME="idx:sesamecurrentrepository3:12"></A><A class="pred" href="#sesame_current_repository/3">sesame_current_repository/3</A>.
Chris@0 473 </DD>
Chris@0 474 </DL>
Chris@0 475
Chris@0 476 <P>Below is a typical call to connect to a sesame server:
Chris@0 477
Chris@0 478 <PRE class="code">
Chris@0 479 ...,
Chris@0 480 set_sesame_default([ host(localhost),
Chris@0 481 port(8080),
Chris@0 482 path('/sesame'),
Chris@0 483 repository('mem-rdfs-db')
Chris@0 484 ]).
Chris@0 485 </PRE>
Chris@0 486
Chris@0 487 </DD>
Chris@0 488 <DT class="pubdef"><A NAME="sesame_current_repository/3"><STRONG>sesame_current_repository</STRONG>(<VAR>-Id,
Chris@0 489 -Properties, +Options</VAR>)</A></DT>
Chris@0 490 <DD class="defbody">
Chris@0 491 Enumerate the currently available Sesame repositories. <VAR>Id</VAR> is
Chris@0 492 unified to the name of the repository. <VAR>Properties</VAR> is a list
Chris@0 493 of <CODE>Name(Value)</CODE> terms providing title and access details.
Chris@0 494 <VAR>Options</VAR> specifies the host, port and path of the server.</DD>
Chris@0 495 <DT class="pubdef"><A NAME="sesame_clear_repository/1"><STRONG>sesame_clear_repository</STRONG>(<VAR>+Options</VAR>)</A></DT>
Chris@0 496 <DD class="defbody">
Chris@0 497 Remove all content from the repository. <VAR>Options</VAR> specifies the
Chris@0 498 host, port and path of the server as well as the target repository.</DD>
Chris@0 499 <DT class="pubdef"><A NAME="sesame_login/3"><STRONG>sesame_login</STRONG>(<VAR>+User,
Chris@0 500 +Password, +Options</VAR>)</A></DT>
Chris@0 501 <DD class="defbody">
Chris@0 502 Login to a Sesame server. On success the returned cookie is stored and
Chris@0 503 transmitted with each query on the same server. <VAR>Options</VAR>
Chris@0 504 specifies the host, port and path of the server.</DD>
Chris@0 505 <DT class="pubdef"><A NAME="sesame_logout/1"><STRONG>sesame_logout</STRONG>(<VAR>+Options</VAR>)</A></DT>
Chris@0 506 <DD class="defbody">
Chris@0 507 <VAR>Options</VAR> specifies the host, port and path of the server.</DD>
Chris@0 508 <DT class="pubdef"><A NAME="sesame_graph_query/3"><STRONG>sesame_graph_query</STRONG>(<VAR>+Query,
Chris@0 509 -Triple, +Options</VAR>)</A></DT>
Chris@0 510 <DD class="defbody">
Chris@0 511 Execute <VAR>Query</VAR> on the given server and return the resulting
Chris@0 512 triples on backtracking. <VAR>Options</VAR> specifies the host, port and
Chris@0 513 path of the server as well as the target repository. The example below
Chris@0 514 extracts all type relations from the default server.
Chris@0 515
Chris@0 516 <PRE class="code">
Chris@0 517 ...,
Chris@0 518 sesame_graph_query('construct * from {s} &lt;rdf:type&gt; {o}',
Chris@0 519 rdf(S,P,O),
Chris@0 520 []),
Chris@0 521 </PRE>
Chris@0 522
Chris@0 523 </DD>
Chris@0 524 <DT class="pubdef"><A NAME="sesame_table_query/3"><STRONG>sesame_table_query</STRONG>(<VAR>+Query,
Chris@0 525 -Row, +Options</VAR>)</A></DT>
Chris@0 526 <DD class="defbody">
Chris@0 527 Execute <VAR>Query</VAR> on the given server and return the resulting
Chris@0 528 rows on backtracking. Each <VAR>Row</VAR> is a term of the format
Chris@0 529 <CODE>row(Col1, Col2, ... ColN)</CODE>. <VAR>Options</VAR> specifies the
Chris@0 530 host, port and path of the server as well as the target repository.</DD>
Chris@0 531 <DT class="pubdef"><A NAME="sesame_extract_rdf/2"><STRONG>sesame_extract_rdf</STRONG>(<VAR>-Triple,
Chris@0 532 +Options</VAR>)</A></DT>
Chris@0 533 <DD class="defbody">
Chris@0 534 Extract all content from an RDF repository. In addition to the server
Chris@0 535 and repository options the following options are defined:
Chris@0 536
Chris@0 537 <DL>
Chris@0 538 <DT><STRONG>schema</STRONG>(<VAR>OnOff</VAR>)</DT>
Chris@0 539 <DD class="defbody">
Chris@0 540 Extract the schema information.
Chris@0 541 </DD>
Chris@0 542 <DT><STRONG>data</STRONG>(<VAR>OnOff</VAR>)</DT>
Chris@0 543 <DD class="defbody">
Chris@0 544 Extract the plain data
Chris@0 545 </DD>
Chris@0 546 <DT><STRONG>explicit_only</STRONG>(<VAR>OnOff</VAR>)</DT>
Chris@0 547 <DD class="defbody">
Chris@0 548 Determine whether or not entailed triples are returned. Default is <CODE>off</CODE>,
Chris@0 549 returning both explicit and inferred triples.
Chris@0 550 </DD>
Chris@0 551 </DL>
Chris@0 552
Chris@0 553 </DD>
Chris@0 554 <DT class="pubdef"><A NAME="sesame_upload_file/+File, +Options"><STRONG>sesame_upload_file</STRONG>(<VAR>+File,
Chris@0 555 +Options</VAR>)</A></DT>
Chris@0 556 <DD class="defbody">
Chris@0 557 dd the content of <VAR>File</VAR> to the repository. In addition to the
Chris@0 558 server and repository options the following options are defined:
Chris@0 559
Chris@0 560 <DL>
Chris@0 561 <DT><STRONG>data_format</STRONG>(<VAR>+Format</VAR>)</DT>
Chris@0 562 <DD class="defbody">
Chris@0 563 Format of the input file. Default is <CODE>rdfxml</CODE>.
Chris@0 564 </DD>
Chris@0 565 <DT><STRONG>base_uri</STRONG>(<VAR>+BaseURI</VAR>)</DT>
Chris@0 566 <DD class="defbody">
Chris@0 567 URI for resolving local names. Default is <CODE>foo:bar</CODE>.
Chris@0 568 </DD>
Chris@0 569 <DT><STRONG>verify_data</STRONG>(<VAR>OnOff</VAR>)</DT>
Chris@0 570 <DD class="defbody">
Chris@0 571 Do/do not verify the input. Default is <CODE>off</CODE>.
Chris@0 572 </DD>
Chris@0 573 </DL>
Chris@0 574
Chris@0 575 </DD>
Chris@0 576 <DT class="pubdef"><A NAME="sesame_assert/2"><STRONG>sesame_assert</STRONG>(<VAR>+TripleOrList,
Chris@0 577 +Options</VAR>)</A></DT>
Chris@0 578 <DD class="defbody">
Chris@0 579 Assert a single <CODE>rdf(Subject, Predicate, Object)</CODE> or a list
Chris@0 580 of such terms. In addition to the server and repository options the
Chris@0 581 following options are defined:
Chris@0 582
Chris@0 583 <DL>
Chris@0 584 <DT><STRONG>base_uri</STRONG>(<VAR>+BaseURI</VAR>)</DT>
Chris@0 585 <DD class="defbody">
Chris@0 586 URI for resolving local names. Default is <CODE>foo:bar</CODE>.
Chris@0 587 </DD>
Chris@0 588 </DL>
Chris@0 589
Chris@0 590 </DD>
Chris@0 591 <DT class="pubdef"><A NAME="sesame_retract/2"><STRONG>sesame_retract</STRONG>(<VAR>+Triple,
Chris@0 592 +Options</VAR>)</A></DT>
Chris@0 593 <DD class="defbody">
Chris@0 594 Remove a triple from the repository. Variables in Triple match all
Chris@0 595 values for that field.
Chris@0 596 </DD>
Chris@0 597 </DL>
Chris@0 598
Chris@0 599 <H2><A NAME="sec:6"><SPAN class="sec-nr">6</SPAN><SPAN class="sec-title">Sesame
Chris@0 600 interoperability</SPAN></A></H2>
Chris@0 601
Chris@0 602 <P>The SWI-Prolog SeRQL engine provides a (still incomplete) drop-in
Chris@0 603 replacement for the Sesame HTTP access protocol. Sesame's remote server
Chris@0 604 class can be used to access the SWI-Prolog SeRQL engine through the
Chris@0 605 Sesame Java API. Likewise the Prolog client realised by
Chris@0 606 <CODE>sesame_client.pl</CODE> provides a Prolog API that can be used to
Chris@0 607 access both Sesame and the SWI-Prolog SeRQL engine.
Chris@0 608
Chris@0 609 <H2><A NAME="sec:7"><SPAN class="sec-nr">7</SPAN><SPAN class="sec-title">The
Chris@0 610 SPARQL client</SPAN></A></H2>
Chris@0 611
Chris@0 612 <P>The file <CODE>sparql_client.pl</CODE> provides a client to the
Chris@0 613 SPARQL HTTP protocol. The protocol defines how a SPARQL query is asked
Chris@0 614 over HTTP and how the results are presented. It is possible to use the
Chris@0 615 SeRQL protocol on the same server to perform tasks such as modifying the
Chris@0 616 triple store.
Chris@0 617
Chris@0 618 <P>The structure of the SPARQL client API is closely based on the SeRQL
Chris@0 619 client.
Chris@0 620
Chris@0 621 <DL>
Chris@0 622 <DT class="pubdef"><A NAME="sparql_query/3"><STRONG>sparql_query</STRONG>(<VAR>+Query,
Chris@0 623 -Row, +Options</VAR>)</A></DT>
Chris@0 624 <DD class="defbody">
Chris@0 625 Run a SPARQL query on a remote server, retrieving the results one-by-one
Chris@0 626 on backtracking. <VAR>Options</VAR> provide the host, port and path of
Chris@0 627 the server. <A NAME="idx:sparqlsetserver1:13"></A><A class="pred" href="#sparql_set_server/1">sparql_set_server/1</A>
Chris@0 628 can be used to define default locations.</DD>
Chris@0 629 <DT class="pubdef"><A NAME="sparql_set_server/1"><STRONG>sparql_set_server</STRONG>(<VAR>+Options</VAR>)</A></DT>
Chris@0 630 <DD class="defbody">
Chris@0 631 List of options that act as defaults for <A NAME="idx:sparqlquery3:14"></A><A class="pred" href="#sparql_query/3">sparql_query/3</A>.
Chris@0 632 Commonly set to specify the server location. For example:
Chris@0 633
Chris@0 634 <PRE class="code">
Chris@0 635 ?- sparql_set_server([ host(localhost),
Chris@0 636 port(3020),
Chris@0 637 path('/sparql/')
Chris@0 638 ]).
Chris@0 639 </PRE>
Chris@0 640
Chris@0 641 <P></DD>
Chris@0 642 </DL>
Chris@0 643
Chris@0 644 <H2><A NAME="sec:8"><SPAN class="sec-nr">8</SPAN><SPAN class="sec-title">Security
Chris@0 645 issues</SPAN></A></H2>
Chris@0 646
Chris@0 647 <P>HTTP Communication with the server, including usernames and
Chris@0 648 passwords, is in cleartext and therefore sensitive to sniffing. The
Chris@0 649 overall security of the server is unknown. It is advised to run the
Chris@0 650 server as user with minimal access rights, only providing write access
Chris@0 651 to the user database file.
Chris@0 652
Chris@0 653 <H2><A NAME="sec:9"><SPAN class="sec-nr">9</SPAN><SPAN class="sec-title">Downloading</SPAN></A></H2>
Chris@0 654
Chris@0 655 <P>The SWI-Prolog SeRQL engine is available from CVS using the following
Chris@0 656 commands:
Chris@0 657
Chris@0 658 <PRE class="code">
Chris@0 659 % cvs -d :pserver:pl@gollem.science.uva.nl:/usr/local/cvspl login
Chris@0 660 Password: prolog
Chris@0 661 % cvs -d :pserver:pl@gollem.science.uva.nl:/usr/local/cvspl co SeRQL
Chris@0 662 </PRE>
Chris@0 663
Chris@0 664 <P>Infrequently announces and snapshots are provided through the
Chris@0 665 <A class="url" href="http://gollem.science.uva.nl/twiki/pl/bin/view/Library/SeRQL">Prolog
Chris@0 666 Wiki</A>
Chris@0 667
Chris@0 668 <H3>Acknowledgements</H3>
Chris@0 669
Chris@0 670 <P>The SeRQL server has been realised as part of the <A class="url" href="http://www.hops-fp6.org">HOPS
Chris@0 671 project</A> and could not have been done without Sesame and feedback
Chris@0 672 from Jeen Broekstra and Maarten Menken from the Free University of
Chris@0 673 Amsterdam (VU). Adding SPARQL support has been realised as part of the
Chris@0 674 E-culture sub-project of Dutch MultiMedia project.
Chris@0 675
Chris@0 676 <H1><A NAME="document-index">Index</A></H1>
Chris@0 677
Chris@0 678 <DL>
Chris@0 679 <DT><STRONG>R</STRONG></DT>
Chris@0 680 <DD>
Chris@0 681 </DD>
Chris@0 682 <DT>rdf/3</DT>
Chris@0 683 <DD>
Chris@0 684 <A class="idx" href="#idx:rdf3:1"></A> <A class="idx" href="#idx:rdf3:2">2</A></DD>
Chris@0 685 <DT><STRONG>S</STRONG></DT>
Chris@0 686 <DD>
Chris@0 687 </DD>
Chris@0 688 <DT><A class="idx" href="#serql_compile/3">serql_compile/3</A></DT>
Chris@0 689 <DD>
Chris@0 690 <A class="idx" href="#idx:serqlcompile3:4">4.1</A> <A class="idx" href="#idx:serqlcompile3:5">4.1</A> <A class="idx" href="#idx:serqlcompile3:7">4.1</A></DD>
Chris@0 691 <DT><A class="idx" href="#serql_query/3">serql_query/3</A></DT>
Chris@0 692 <DD>
Chris@0 693 <A class="idx" href="#idx:serqlquery3:9">4.1</A></DD>
Chris@0 694 <DT><A class="idx" href="#serql_run/2">serql_run/2</A></DT>
Chris@0 695 <DD>
Chris@0 696 <A class="idx" href="#idx:serqlrun2:3">4.1</A> <A class="idx" href="#idx:serqlrun2:6">4.1</A> <A class="idx" href="#idx:serqlrun2:8">4.1</A></DD>
Chris@0 697 <DT><A class="idx" href="#sesame_assert/2">sesame_assert/2</A></DT>
Chris@0 698 <DD>
Chris@0 699 </DD>
Chris@0 700 <DT><A class="idx" href="#sesame_clear_repository/1">sesame_clear_repository/1</A></DT>
Chris@0 701 <DD>
Chris@0 702 </DD>
Chris@0 703 <DT><A class="idx" href="#sesame_current_repository/3">sesame_current_repository/3</A></DT>
Chris@0 704 <DD>
Chris@0 705 <A class="idx" href="#idx:sesamecurrentrepository3:12">5</A></DD>
Chris@0 706 <DT><A class="idx" href="#sesame_extract_rdf/2">sesame_extract_rdf/2</A></DT>
Chris@0 707 <DD>
Chris@0 708 </DD>
Chris@0 709 <DT><A class="idx" href="#sesame_graph_query/3">sesame_graph_query/3</A></DT>
Chris@0 710 <DD>
Chris@0 711 </DD>
Chris@0 712 <DT><A class="idx" href="#sesame_login/3">sesame_login/3</A></DT>
Chris@0 713 <DD>
Chris@0 714 </DD>
Chris@0 715 <DT><A class="idx" href="#sesame_logout/1">sesame_logout/1</A></DT>
Chris@0 716 <DD>
Chris@0 717 </DD>
Chris@0 718 <DT><A class="idx" href="#sesame_retract/2">sesame_retract/2</A></DT>
Chris@0 719 <DD>
Chris@0 720 </DD>
Chris@0 721 <DT><A class="idx" href="#sesame_table_query/3">sesame_table_query/3</A></DT>
Chris@0 722 <DD>
Chris@0 723 </DD>
Chris@0 724 <DT><A class="idx" href="#sesame_upload_file/+File, +Options">sesame_upload_file/+File,
Chris@0 725 +Options</A></DT>
Chris@0 726 <DD>
Chris@0 727 </DD>
Chris@0 728 <DT><A class="idx" href="#set_sesame_default/1">set_sesame_default/1</A></DT>
Chris@0 729 <DD>
Chris@0 730 <A class="idx" href="#idx:setsesamedefault1:11">5</A></DD>
Chris@0 731 <DT>setting/1</DT>
Chris@0 732 <DD>
Chris@0 733 <A class="idx" href="#idx:setting1:10">4.2</A></DD>
Chris@0 734 <DT><A class="idx" href="#sparql_compile/3">sparql_compile/3</A></DT>
Chris@0 735 <DD>
Chris@0 736 </DD>
Chris@0 737 <DT><A class="idx" href="#sparql_query/3">sparql_query/3</A></DT>
Chris@0 738 <DD>
Chris@0 739 <A class="idx" href="#idx:sparqlquery3:14">7</A></DD>
Chris@0 740 <DT><A class="idx" href="#sparql_run/2">sparql_run/2</A></DT>
Chris@0 741 <DD>
Chris@0 742 </DD>
Chris@0 743 <DT><A class="idx" href="#sparql_set_server/1">sparql_set_server/1</A></DT>
Chris@0 744 <DD>
Chris@0 745 <A class="idx" href="#idx:sparqlsetserver1:13">7</A></DD>
Chris@0 746 </DL>
Chris@0 747
Chris@0 748 </BODY></HTML>