Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Documentation updates.

  • Loading branch information...
commit d3744b220d5929b1534ce203a47f0c0049caf26c 1 parent f312d28
Philip Fennell authored
472 docs/api/md/xqdoc_xquery_lib-gsp.xqy.html
View
@@ -0,0 +1,472 @@
+<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta http-equiv="Generator" content="xquerydoc - https://github.com/xquery/xquerydoc"/><title>xqDoc - </title><style type="text/css">
+ body {
+ font-family: Helvetica;
+ padding: 0.5em 1em;
+ }
+ pre {
+ font-family: Inconsolata, Consolas, monospace;
+ }
+ ol.results {
+ padding-left: 0;
+ }
+ .footer {
+ text-align:right;
+ border-top: solid 4px;
+ padding: 0.25em 0.5em;
+ font-size: 85%;
+ color: #999;
+ }
+ li.result {
+ list-style-position: inside;
+ list-style: none;
+ height:140px;
+ }
+ h2 {
+ display: inline-block;
+ margin: 0;
+ }
+
+ h2 a,
+ .result h3 a {
+ text-decoration: inherit;
+ color: inherit;
+ }
+ h3{
+ font-size: 140%;
+ background-color: #aaa;
+ border-bottom: 1px solid #000;
+ width: 100%;
+ }
+ h4{
+ font-size: 100%;
+ background-color: #ddd;
+ width: 90%;
+ }
+
+ .namespace {
+ color: #999;
+ }
+ .namespace:before {
+ content: "{";
+ }
+ .namespace:after {
+ content: "}";
+ }
+ table{
+ width:75%;
+ float:right;
+ }
+ td {
+ height:100px;
+ width:50%;
+ vertical-align:text-top;
+ }
+ </style><script src="lib/prettify.js" type="text/javascript"> </script><script src="lib/lang-xq.js" type="text/javascript"> </script><link rel="stylesheet" type="text/css" href="lib/prettify.css"/></head><body class="home"><div id="main"><h1><span class="namespace">http://www.w3.org/TR/sparql11-http-rdf-update/</span>  library module </h1><div id="variables"><h3>Variables</h3><div id="var_USER_AGENT"><h4><pre class="prettyprint lang-xq"><u>Variable</u>: $USER_AGENT as xs:string</pre></h4><p>User-agent string.</p></div><div id="var_RDF_XML"><h4><pre class="prettyprint lang-xq"><u>Variable</u>: $RDF_XML as xs:string</pre></h4><p>MIME-Types.</p></div><div id="var_NTRIPLES"><h4><pre class="prettyprint lang-xq"><u>Variable</u>: $NTRIPLES as xs:string</pre></h4></div><div id="var_TURTLE"><h4><pre class="prettyprint lang-xq"><u>Variable</u>: $TURTLE as xs:string</pre></h4></div></div><div id="functions"><h3>Functions</h3><div id="func_gsp_retrieve-default-graph-metainfo_1"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:retrieve-default-graph-metainfo($uri as xs:string
+) as element(http:response)</pre></h4><p>Retrieve the default graph's metainformation.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo.</li></ul></div><div id="func_gsp_retrieve-named-graph-metainfo_2"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:retrieve-named-graph-metainfo($uri as xs:string,
+ $graphURI as xs:string?
+) as element(http:response)</pre></h4><p>Retrieve the named graph's metainformation.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>graphURI as xs:string? the named graph URIs</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo.</li></ul></div><div id="func_gsp_retrieve-graph-metainfo_3"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:retrieve-graph-metainfo($uri as xs:string,
+ $default as xs:boolean?, $graphURI as xs:string?
+) as element(http:response)</pre></h4><p>Retrieve a graph's metainformation.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>default as xs:boolean? selects the 'default' graph.</li><li>graphURI as xs:string? the named graph URIs</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo.</li></ul></div><div id="func_gsp_retrieve-default-graph_1"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:retrieve-default-graph($uri as xs:string
+) as element(http:response)</pre></h4><p>Retrieve the default graph as application/rdf+xml serialisation.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo and response body.</li></ul></div><div id="func_gsp_retrieve-default-graph_2"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:retrieve-default-graph($uri as xs:string,
+ $mediaType as xs:string
+) as element(http:response)</pre></h4><p>Retrieve the default graph as requested serialisation.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>mediaType as xs:string the content-type that will be acceptable to the client.</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo and response body.</li></ul></div><div id="func_gsp_retrieve-named-graph_2"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:retrieve-named-graph($uri as xs:string,
+ $graphURI as xs:string
+) as element(http:response)</pre></h4><p>Retrieve the default graph as application/rdf+xml serialisation.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>graphURI as xs:string the named graph URIs</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo and response body.</li></ul></div><div id="func_gsp_retrieve-named-graph_3"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:retrieve-named-graph($uri as xs:string,
+ $graphURI as xs:string, $mediaType as xs:string
+) as element(http:response)</pre></h4><p>Retrieve the default graph as requested serialisation.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>graphURI as xs:string the named graph URIs</li><li>mediaType as xs:string the content-type that will be acceptable to the client.</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo and response body.</li></ul></div><div id="func_gsp_retrieve-graph_4"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:retrieve-graph($uri as xs:string,
+ $default as xs:boolean?, $graphURI as xs:string?,
+ $mediaType as xs:string
+) as element(http:response)</pre></h4><p>Retrieve a graph specifiying the required serialisation.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>default as xs:boolean? selects the 'default' graph.</li><li>graphURI as xs:string? the named graph URIs</li><li>mediaType as xs:string the content-type that will be acceptable to the client.</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo and response body.</li></ul></div><div id="func_gsp_merge-default-graph_2"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:merge-default-graph($uri as xs:string,
+ $graphContent as item()
+) as element(http:response)</pre></h4><p>Merge the default graph - merges the context graph with submitted graph.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>graphContent as item() the graph.</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo.</li></ul></div><div id="func_gsp_merge-named-graph_3"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:merge-named-graph($uri as xs:string,
+ $graphURI as xs:string, $graphContent as item()
+) as element(http:response)</pre></h4><p>Merge the default graph - merges the context graph with submitted graph.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>graphURI as xs:string the named graph URIs.</li><li>graphContent as item() the graph.</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo.</li></ul></div><div id="func_gsp_merge-graph_4"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:merge-graph($uri as xs:string, $default as xs:boolean?,
+ $graphURI as xs:string?, $graphContent as item()
+) as element(http:response)</pre></h4><p>Merge Graph - merges current graph with submitted graph.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>default as xs:boolean? selects the 'default' graph.</li><li>graphURI as xs:string? the named graph URIs.</li><li>graphContent as item() the graph.</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo.</li></ul></div><div id="func_gsp_add-default-graph_2"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:add-default-graph($uri as xs:string,
+ $graphContent as item()
+) as element(http:response)</pre></h4><p>Add Graph - replaces current default graph with the submitted graph.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>graphContent as item()</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo.</li></ul></div><div id="func_gsp_add-named-graph_3"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:add-named-graph($uri as xs:string,
+ $graphURI as xs:string, $graphContent as item()
+) as element(http:response)</pre></h4><p>Add Graph - replaces the named graph with the submitted graph.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>graphURI as xs:string the named graph URIs</li><li>graphContent as item()</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo.</li></ul></div><div id="func_gsp_add-graph_4"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:add-graph($uri as xs:string,
+ $default as xs:boolean?, $graphURI as xs:string?,
+ $graphContent as item()
+) as element(http:response)</pre></h4><p>Add Graph - replaces the current graph with the submitted graph.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>default as xs:boolean?</li><li>graphURI as xs:string?</li><li>graphContent as item()</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element containing HTTP metainfo.</li></ul></div><div id="func_gsp_delete-default-graph_1"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:delete-default-graph($uri as xs:string
+) as element(http:response)</pre></h4><p>Delete the default graph.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo.</li></ul></div><div id="func_gsp_delete-named-graph_2"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:delete-named-graph($uri as xs:string,
+ $graphURI as xs:string
+) as element(http:response)</pre></h4><p>Delete the named graph.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>graphURI as xs:string the named graph URIs</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element containing HTTP metainfo.</li></ul></div><div id="func_gsp_delete-graph_3"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:delete-graph($uri as xs:string, $default as xs:boolean?,
+ $graphURI as xs:string?
+) as element(http:response)</pre></h4><p>Delete a graph.</p><h5>Params</h5><ul><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>default as xs:boolean? selects the 'default' graph.</li><li>graphURI as xs:string? the named graph URIs</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element contains HTTP metainfo.</li></ul></div><div id="func_gsp_data_1"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:data($response as element(http:response)
+) as item()*</pre></h4><p>Extracts the content of the response body or throws an error if the response XML fragment indicates an error response from the Graph Store.</p>GSP002 - Graph Store Reports an Error.<h5>Params</h5><ul><li>response as element(http:response) the HTTP response fragment.</li></ul><h5>Returns</h5><ul><li> item()*: either an XML fragment or a string depending upon the response content-type.</li></ul></div><div id="func_gsp_submission_6"><h4><pre class="prettyprint lang-xq"><u>Function</u>: gsp:submission($method as xs:string, $uri as xs:string, $default as xs:boolean?,
+ $graphURI as xs:string*, $mediaType as xs:string, $graphContent as item()?
+) as
+ element(http:request)</pre></h4><p>Builds an XML fragment that carries the request details.</p>GSP001 - The default and graph parameters cannot be used together.<h5>Params</h5><ul><li>method as xs:string HTTP method (HEAD|GET|POST|PUT|DELETE)</li><li>uri as xs:string the URL of the target Graph Store end-point.</li><li>default as xs:boolean? selects the 'default' graph.</li><li>graphURI as xs:string* the named graph URIs</li><li>mediaType as xs:string Media MIME-Type for the HTTP accpet header</li><li>graphContent as item()? An RDF graph.</li></ul><h5>Returns</h5><ul><li>
+ element(http:request): the HTTP request XML fragment.</li></ul></div></div><div><h3>Original Source Code</h3><pre class="prettyprint lang-xq">xquery version "1.0" encoding "utf-8";
+
+(:
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+ :)
+
+(:~
+ : This library provides functions for accessing and managing RDF Graph Stores
+ : that implement the W3C's Graph Store HTTP Protocol:
+ : &lt;http://www.w3.org/TR/sparql11-http-rdf-update/&gt;
+ : @author Philip A. R. Fennell
+ : @version 0.2
+ :)
+
+module namespace gsp = "http://www.w3.org/TR/sparql11-http-rdf-update/";
+
+import module namespace impl = "http://www.marklogic.com/http" at
+ "lib-ml.xqy";
+
+declare default function namespace "http://www.w3.org/2005/xpath-functions";
+declare namespace http = "http://www.w3.org/Protocols/rfc2616";
+
+(:~ User-agent string. :)
+declare variable $USER_AGENT as xs:string := "xqy-graph-store-http-protocol-client/0.2";
+
+(:~ MIME-Types. :)
+declare variable $RDF_XML as xs:string := "application/rdf+xml";
+declare variable $NTRIPLES as xs:string := "text/plain";
+declare variable $TURTLE as xs:string := "text/turtle";
+
+
+(:~
+ : Retrieve the default graph's metainformation.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @return an http:response element contains HTTP metainfo.
+ :)
+declare function gsp:retrieve-default-graph-metainfo($uri as xs:string)
+ as element(http:response)
+{
+ gsp:retrieve-graph-metainfo($uri, true(), ())
+};
+
+
+(:~
+ : Retrieve the named graph's metainformation.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $graphURI the named graph URIs
+ : @return an http:response element contains HTTP metainfo.
+ :)
+declare function gsp:retrieve-named-graph-metainfo($uri as xs:string,
+ $graphURI as xs:string?)
+ as element(http:response)
+{
+ gsp:retrieve-graph-metainfo($uri, (), $graphURI)
+};
+
+
+(:~
+ : Retrieve a graph's metainformation.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $default selects the 'default' graph.
+ : @param $graphURI the named graph URIs
+ : @return an http:response element contains HTTP metainfo.
+ :)
+declare (: private :) function gsp:retrieve-graph-metainfo($uri as xs:string,
+ $default as xs:boolean?, $graphURI as xs:string?)
+ as element(http:response)
+{
+ impl:normalise-response(
+ impl:http-request(gsp:submission('HEAD', $uri,
+ $default, $graphURI, $RDF_XML, ())))
+};
+
+
+(:~
+ : Retrieve the default graph as application/rdf+xml serialisation.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @return an http:response element contains HTTP metainfo and response body.
+ :)
+declare function gsp:retrieve-default-graph($uri as xs:string)
+ as element(http:response)
+{
+ gsp:retrieve-graph($uri, true(), (), $RDF_XML)
+};
+
+
+(:~
+ : Retrieve the default graph as requested serialisation.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $mediaType the content-type that will be acceptable to the client.
+ : @return an http:response element contains HTTP metainfo and response body.
+ :)
+declare function gsp:retrieve-default-graph($uri as xs:string,
+ $mediaType as xs:string)
+ as element(http:response)
+{
+ gsp:retrieve-graph($uri, true(), (), $mediaType)
+};
+
+
+(:~
+ : Retrieve the default graph as application/rdf+xml serialisation.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $graphURI the named graph URIs
+ : @return an http:response element contains HTTP metainfo and response body.
+ :)
+declare function gsp:retrieve-named-graph($uri as xs:string,
+ $graphURI as xs:string)
+ as element(http:response)
+{
+ gsp:retrieve-graph($uri, (), $graphURI, $RDF_XML)
+};
+
+
+(:~
+ : Retrieve the default graph as requested serialisation.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $graphURI the named graph URIs
+ : @param $mediaType the content-type that will be acceptable to the client.
+ : @return an http:response element contains HTTP metainfo and response body.
+ :)
+declare function gsp:retrieve-named-graph($uri as xs:string,
+ $graphURI as xs:string, $mediaType as xs:string)
+ as element(http:response)
+{
+ gsp:retrieve-graph($uri, (), $graphURI, $mediaType)
+};
+
+
+(:~
+ : Retrieve a graph specifiying the required serialisation.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $default selects the 'default' graph.
+ : @param $graphURI the named graph URIs
+ : @param $mediaType the content-type that will be acceptable to the client.
+ : @return an http:response element contains HTTP metainfo and response body.
+ :)
+declare (: private :) function gsp:retrieve-graph($uri as xs:string,
+ $default as xs:boolean?, $graphURI as xs:string?,
+ $mediaType as xs:string)
+ as element(http:response)
+{
+ impl:normalise-response(
+ impl:http-request(gsp:submission('GET', $uri, $default, $graphURI,
+ $mediaType, ())))
+};
+
+
+(:~
+ : Merge the default graph - merges the context graph with submitted graph.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $graphContent the graph.
+ : @return an http:response element contains HTTP metainfo.
+ :)
+declare function gsp:merge-default-graph($uri as xs:string,
+ $graphContent as item())
+ as element(http:response)
+{
+ gsp:merge-graph($uri, true(), (), $graphContent)
+};
+
+
+(:~
+ : Merge the default graph - merges the context graph with submitted graph.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $graphURI the named graph URIs.
+ : @param $graphContent the graph.
+ : @return an http:response element contains HTTP metainfo.
+ :)
+declare function gsp:merge-named-graph($uri as xs:string,
+ $graphURI as xs:string, $graphContent as item())
+ as element(http:response)
+{
+ gsp:merge-graph($uri, (), $graphURI, $graphContent)
+};
+
+
+(:~
+ : Merge Graph - merges current graph with submitted graph.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $default selects the 'default' graph.
+ : @param $graphURI the named graph URIs.
+ : @param $graphContent the graph.
+ : @return an http:response element contains HTTP metainfo.
+ :)
+declare (: private :) function gsp:merge-graph($uri as xs:string, $default as xs:boolean?,
+ $graphURI as xs:string?, $graphContent as item())
+ as element(http:response)
+{
+ impl:normalise-response(
+ impl:http-request(gsp:submission('POST', $uri, $default, $graphURI,
+ $RDF_XML, $graphContent)))
+};
+
+
+(:~
+ : Add Graph - replaces current default graph with the submitted graph.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @return an http:response element contains HTTP metainfo.
+ :)
+declare function gsp:add-default-graph($uri as xs:string,
+ $graphContent as item())
+ as element(http:response)
+{
+ gsp:add-graph($uri, true(), (), $graphContent)
+};
+
+
+(:~
+ : Add Graph - replaces the named graph with the submitted graph.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $graphURI the named graph URIs
+ : @return an http:response element contains HTTP metainfo.
+ :)
+declare function gsp:add-named-graph($uri as xs:string,
+ $graphURI as xs:string, $graphContent as item())
+ as element(http:response)
+{
+ gsp:add-graph($uri, (), $graphURI, $graphContent)
+};
+
+
+(:~
+ : Add Graph - replaces the current graph with the submitted graph.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @return an http:response element containing HTTP metainfo.
+ :)
+declare (: private :) function gsp:add-graph($uri as xs:string,
+ $default as xs:boolean?, $graphURI as xs:string?,
+ $graphContent as item())
+ as element(http:response)
+{
+ impl:normalise-response(
+ impl:http-request(gsp:submission('PUT', $uri, $default, $graphURI,
+ $RDF_XML, $graphContent)))
+};
+
+
+(:~
+ : Delete the default graph.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $default selects the 'default' graph.
+ : @param $graphURI the named graph URIs
+ : @return an http:response element contains HTTP metainfo.
+ :)
+declare function gsp:delete-default-graph($uri as xs:string)
+ as element(http:response)
+{
+ gsp:delete-graph($uri, true(), ())
+};
+
+
+(:~
+ : Delete the named graph.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $graphURI the named graph URIs
+ : @return an http:response element containing HTTP metainfo.
+ :)
+declare function gsp:delete-named-graph($uri as xs:string,
+ $graphURI as xs:string)
+ as element(http:response)
+{
+ gsp:delete-graph($uri, (), $graphURI)
+};
+
+
+(:~
+ : Delete a graph.
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $default selects the 'default' graph.
+ : @param $graphURI the named graph URIs
+ : @return an http:response element contains HTTP metainfo.
+ :)
+declare (: private :) function gsp:delete-graph($uri as xs:string, $default as xs:boolean?,
+ $graphURI as xs:string?)
+ as element(http:response)
+{
+ impl:normalise-response(
+ impl:http-request(gsp:submission('DELETE', $uri, $default,
+ $graphURI, $RDF_XML, ())))
+};
+
+
+(:~
+ : Extracts the content of the response body or throws an error if the response
+ : XML fragment indicates an error response from the Graph Store.
+ : @param $response the HTTP response fragment.
+ : @return either an XML fragment or a string depending upon the response
+ : content-type.
+ : @throws GSP002 - Graph Store Reports an Error.
+ :)
+declare function gsp:data($response as element(http:response))
+ as item()*
+{
+ (:
+ : If the response status code is less than 400 then assume all is well,
+ : otherwise throw an exception with the response message in it.
+ :)
+ if (number($response/@status) lt 400) then
+ typeswitch ($response/http:body/(* | text()))
+ case $body as text()
+ return
+ string($response/http:body/text())
+ default
+ return
+ $response/http:body/*
+ else
+ error(
+ xs:QName('GSP002'),
+ 'Graph Store Reports an Error.',
+ string($response/http:body/text())
+ )
+};
+
+
+
+
+(:~
+ : Builds an XML fragment that carries the request details.
+ : @param $method HTTP method (HEAD|GET|POST|PUT|DELETE)
+ : @param $uri the URL of the target Graph Store end-point.
+ : @param $default selects the 'default' graph.
+ : @param $graphURI the named graph URIs
+ : @param $mediaType Media MIME-Type for the HTTP accpet header
+ : @param $graphContent An RDF graph.
+ : @throws GSP001 - The default and graph parameters cannot be used together.
+ : @return the HTTP request XML fragment.
+ :)
+declare (: private :) function gsp:submission($method as xs:string, $uri as xs:string, $default as xs:boolean?,
+ $graphURI as xs:string*, $mediaType as xs:string, $graphContent as item()?) as
+ element(http:request)
+{
+ let $defaultParam as xs:string? := if ($default) then 'default' else ()
+ let $namedGraphParam as xs:string? := if (string-length($graphURI) gt 0) then concat('graph=', $graphURI) else ()
+ let $requestParams as xs:string := string-join(($defaultParam, $namedGraphParam), '&amp;amp;')
+ return
+ if (matches($requestParams, 'default') and matches($requestParams, 'graph')) then
+ error(
+ xs:QName('GSP001'),
+ 'The default and graph parameters cannot be used together.'
+ )
+ else
+ &lt;request xmlns="http://www.w3.org/Protocols/rfc2616" method="{$method}"
+ href="{concat($uri, if (exists($requestParams)) then concat('?', $requestParams) else '')}"&gt;
+ &lt;header name="accept" value="{$mediaType}"/&gt;
+ &lt;header name="user-agent" value="{$USER_AGENT}"/&gt;
+ &lt;header name="content-type" value="{$RDF_XML}"/&gt;
+ &lt;header name="encoding" value="UTF-8"/&gt;
+ {
+ if (exists($graphContent)) then
+ &lt;body xmlns="http://www.w3.org/Protocols/rfc2616"
+ content-type="{$RDF_XML}"&gt;{$graphContent}&lt;/body&gt;
+ else
+ ()
+ }
+ &lt;/request&gt;
+};
+</pre></div><br/><div class="footer"><p style="text-align:right"><i/> |
+ generated by xquerydoc <a href="https://github.com/xquery/xquerydoc" target="xquerydoc">https://github.com/xquery/xquerydoc</a></p></div></div><script type="application/javascript">
+ window.onload = function(){ prettyPrint(); }
+ </script></body></html>
20 docs/api/md/xqdoc_xquery_lib-gsp.xqy.md
View
@@ -4,7 +4,7 @@
## Table of Contents
* Variables: [$USER_AGENT](#var_USER_AGENT), [$RDF_XML](#var_RDF_XML), [$NTRIPLES](#var_NTRIPLES), [$TURTLE](#var_TURTLE)
-* Functions: [gsp:retrieve-default-graph-metainfo\#1](#func_gsp_retrieve-default-graph-metainfo_1), [gsp:retrieve-named-graph-metainfo\#2](#func_gsp_retrieve-named-graph-metainfo_2), [gsp:retrieve-graph-metainfo\#3](#func_gsp_retrieve-graph-metainfo_3), [gsp:retrieve-default-graph\#1](#func_gsp_retrieve-default-graph_1), [gsp:retrieve-default-graph\#2](#func_gsp_retrieve-default-graph_2), [gsp:retrieve-named-graph\#2](#func_gsp_retrieve-named-graph_2), [gsp:retrieve-named-graph\#3](#func_gsp_retrieve-named-graph_3), [gsp:retrieve-graph\#4](#func_gsp_retrieve-graph_4), [gsp:merge-default-graph\#2](#func_gsp_merge-default-graph_2), [gsp:merge-named-graph\#3](#func_gsp_merge-named-graph_3), [gsp:merge-graph\#4](#func_gsp_merge-graph_4), [gsp:add-default-graph\#2](#func_gsp_add-default-graph_2), [gsp:add-named-graph\#3](#func_gsp_add-named-graph_3), [gsp:add-graph\#4](#func_gsp_add-graph_4), [gsp:delete-default-graph\#1](#func_gsp_delete-default-graph_1), [gsp:delete-named-graph\#2](#func_gsp_delete-named-graph_2), [gsp:delete-graph\#3](#func_gsp_delete-graph_3), [gsp:submission\#6](#func_gsp_submission_6)
+* Functions: [gsp:retrieve-default-graph-metainfo\#1](#func_gsp_retrieve-default-graph-metainfo_1), [gsp:retrieve-named-graph-metainfo\#2](#func_gsp_retrieve-named-graph-metainfo_2), [gsp:retrieve-graph-metainfo\#3](#func_gsp_retrieve-graph-metainfo_3), [gsp:retrieve-default-graph\#1](#func_gsp_retrieve-default-graph_1), [gsp:retrieve-default-graph\#2](#func_gsp_retrieve-default-graph_2), [gsp:retrieve-named-graph\#2](#func_gsp_retrieve-named-graph_2), [gsp:retrieve-named-graph\#3](#func_gsp_retrieve-named-graph_3), [gsp:retrieve-graph\#4](#func_gsp_retrieve-graph_4), [gsp:merge-default-graph\#2](#func_gsp_merge-default-graph_2), [gsp:merge-named-graph\#3](#func_gsp_merge-named-graph_3), [gsp:merge-graph\#4](#func_gsp_merge-graph_4), [gsp:add-default-graph\#2](#func_gsp_add-default-graph_2), [gsp:add-named-graph\#3](#func_gsp_add-named-graph_3), [gsp:add-graph\#4](#func_gsp_add-graph_4), [gsp:delete-default-graph\#1](#func_gsp_delete-default-graph_1), [gsp:delete-named-graph\#2](#func_gsp_delete-named-graph_2), [gsp:delete-graph\#3](#func_gsp_delete-graph_3), [gsp:data\#1](#func_gsp_data_1), [gsp:submission\#6](#func_gsp_submission_6)
## Variables
@@ -375,6 +375,22 @@ gsp:delete-graph($uri as xs:string, $default as xs:boolean?,
#### Returns
* element(http:response): an http:response element contains HTTP metainfo.
+### <a name="func_gsp_data_1"/> gsp:data\#1
+```xquery
+gsp:data($response as element(http:response)
+) as item()*
+```
+ Extracts the content of the response body or throws an error if the response XML fragment indicates an error response from the Graph Store.
+
+ GSP002 - Graph Store Reports an Error.
+#### Params
+
+* $response as element(http:response) the HTTP response fragment.
+
+
+#### Returns
+* item()\*: either an XML fragment or a string depending upon the response content-type.
+
### <a name="func_gsp_submission_6"/> gsp:submission\#6
```xquery
gsp:submission($method as xs:string, $uri as xs:string, $default as xs:boolean?,
@@ -384,7 +400,7 @@ gsp:submission($method as xs:string, $uri as xs:string, $default as xs:boolean?,
```
Builds an XML fragment that carries the request details.
- GSP001 The default and graph parameters cannot be used together.
+ GSP001 - The default and graph parameters cannot be used together.
#### Params
* $method as xs:string HTTP method (HEAD|GET|POST|PUT|DELETE)
230 docs/api/md/xqdoc_xquery_lib-ml.xqy.html
View
@@ -0,0 +1,230 @@
+<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta http-equiv="Generator" content="xquerydoc - https://github.com/xquery/xquerydoc"/><title>xqDoc - </title><style type="text/css">
+ body {
+ font-family: Helvetica;
+ padding: 0.5em 1em;
+ }
+ pre {
+ font-family: Inconsolata, Consolas, monospace;
+ }
+ ol.results {
+ padding-left: 0;
+ }
+ .footer {
+ text-align:right;
+ border-top: solid 4px;
+ padding: 0.25em 0.5em;
+ font-size: 85%;
+ color: #999;
+ }
+ li.result {
+ list-style-position: inside;
+ list-style: none;
+ height:140px;
+ }
+ h2 {
+ display: inline-block;
+ margin: 0;
+ }
+
+ h2 a,
+ .result h3 a {
+ text-decoration: inherit;
+ color: inherit;
+ }
+ h3{
+ font-size: 140%;
+ background-color: #aaa;
+ border-bottom: 1px solid #000;
+ width: 100%;
+ }
+ h4{
+ font-size: 100%;
+ background-color: #ddd;
+ width: 90%;
+ }
+
+ .namespace {
+ color: #999;
+ }
+ .namespace:before {
+ content: "{";
+ }
+ .namespace:after {
+ content: "}";
+ }
+ table{
+ width:75%;
+ float:right;
+ }
+ td {
+ height:100px;
+ width:50%;
+ vertical-align:text-top;
+ }
+ </style><script src="lib/prettify.js" type="text/javascript"> </script><script src="lib/lang-xq.js" type="text/javascript"> </script><link rel="stylesheet" type="text/css" href="lib/prettify.css"/></head><body class="home"><div id="main"><h1><span class="namespace">http://www.marklogic.com/http</span>  library module </h1><p>This library module provides MarkLogic spcific XQuery implementation features such as HTTP GET and POST requests and XML parsing.</p><p>Author: Philip A. R. Fennell </p><div id="variables"><h3>Variables</h3><div id="var_URL_ENCODED"><h4><pre class="prettyprint lang-xq"><u>Variable</u>: $URL_ENCODED as xs:string</pre></h4><p>URL encoding for HTTP requests.</p></div></div><div id="functions"><h3>Functions</h3><div id="func_impl_http-request_1"><h4><pre class="prettyprint lang-xq"><u>Function</u>: impl:http-request($request as element(http:request)
+) as item()*</pre></h4><p>The HTTP binding for query operation.</p><h5>Params</h5><ul><li>request as element(http:request)</li></ul><h5>Returns</h5><ul><li> item()*: the normalised response.</li></ul></div><div id="func_impl_normalise-response_1"><h4><pre class="prettyprint lang-xq"><u>Function</u>: impl:normalise-response($response as item()*
+) as element(http:response)</pre></h4><p>Converts the implementation specific representation of the HTTP response into a generic HTTP representation which uses the same structure as XProc's c:response element.</p><h5>Params</h5><ul><li>response as item()*</li></ul><h5>Returns</h5><ul><li> element(http:response): an http:response element</li></ul></div><div id="func_impl_unquote_1"><h4><pre class="prettyprint lang-xq"><u>Function</u>: impl:unquote($string as xs:string
+) as document-node()</pre></h4><p>Parses a string as XML, returning one or more document nodes.</p><h5>Params</h5><ul><li>string as xs:string Input to be unquoted.</li></ul><h5>Returns</h5><ul><li> document-node(): an XML document node.</li></ul></div><div id="func_impl_quote_1"><h4><pre class="prettyprint lang-xq"><u>Function</u>: impl:quote($node as node()
+) as xs:string</pre></h4><p>Parses a string as XML, returning one or more document nodes.</p><h5>Params</h5><ul><li>node as node()</li></ul><h5>Returns</h5><ul><li> xs:string: an XML document node.</li></ul></div><div id="func_impl_build-request-options_1"><h4><pre class="prettyprint lang-xq"><u>Function</u>: impl:build-request-options($request as element(http:request)
+) as element(xhttp:options)</pre></h4><p>Creates the HTTP Request options XML fragment</p><h5>Params</h5><ul><li>request as element(http:request)</li></ul><h5>Returns</h5><ul><li> element(xhttp:options): options element</li></ul></div><div id="func_impl_get-response-head_1"><h4><pre class="prettyprint lang-xq"><u>Function</u>: impl:get-response-head($response as item()*
+) as element(xhttp:response)</pre></h4><p>Extract the head of the HTTP resonse data.</p><h5>Params</h5><ul><li>response as item()*</li></ul><h5>Returns</h5><ul><li> element(xhttp:response): the head of the HTTP response data.</li></ul></div><div id="func_impl_get-response-body_1"><h4><pre class="prettyprint lang-xq"><u>Function</u>: impl:get-response-body($response as item()*
+) as item()?</pre></h4><p>Extract the body of the HTTP resonse data.</p><h5>Params</h5><ul><li>response as item()*</li></ul><h5>Returns</h5><ul><li> item()?: a sequence of zero or more HTTP response body items.</li></ul></div></div><div><h3>Original Source Code</h3><pre class="prettyprint lang-xq">xquery version "1.0-ml" encoding "utf-8";
+
+(:
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+ :)
+
+(:~
+ : This library module provides MarkLogic spcific XQuery implementation features
+ : such as HTTP GET and POST requests and XML parsing.
+ : @author Philip A. R. Fennell
+ :)
+
+module namespace impl = "http://www.marklogic.com/http";
+
+declare default function namespace "http://www.w3.org/2005/xpath-functions";
+declare default element namespace "http://www.w3.org/Protocols/rfc2616";
+
+declare namespace http = "http://www.w3.org/Protocols/rfc2616";
+declare namespace xhttp = "xdmp:http";
+
+(:~ URL encoding for HTTP requests. :)
+declare variable $URL_ENCODED as xs:string := "application/x-www-form-urlencoded";
+
+
+(:~
+ : The HTTP binding for query operation.
+ : @param $request
+ : @return the normalised response.
+ :)
+declare function impl:http-request($request as element(http:request))
+ as item()*
+{
+ let $requestURI as xs:string := $request/@href
+ let $method as xs:string := $request/@method
+ let $log := xdmp:log(concat('[XQuery][GRASP] Request:&amp;#10;', xdmp:quote($request)), 'debug')
+ let $response as item()* :=
+ xdmp:apply(
+ xdmp:function(xs:QName(concat('xdmp:http-', lower-case($method)))),
+ $requestURI,
+ impl:build-request-options($request)
+ )
+ return
+ $response
+};
+
+
+(:~
+ : Converts the implementation specific representation of the HTTP response into
+ : a generic HTTP representation which uses the same structure as XProc's c:response element.
+ : @param $response
+ : @return an http:response element
+ :)
+declare function impl:normalise-response($response as item()*)
+ as element(http:response)
+{
+ &lt;response status="{string(impl:get-response-head($response)/xhttp:code)}"&gt;{
+ (for $header in impl:get-response-head($response)/xhttp:headers/xhttp:*
+ return
+ &lt;header name="{local-name($header)}" value="{string($header)}"/&gt;),
+ if (exists(impl:get-response-body($response))) then
+ &lt;body content-type="{subsequence(tokenize(string(impl:get-response-head($response)/xhttp:headers/xhttp:content-type), ';'), 1, 1)}"&gt;{
+ impl:get-response-body($response)
+ }&lt;/body&gt;
+ else
+ ()
+ }&lt;/response&gt;
+};
+
+
+(:~
+ : Parses a string as XML, returning one or more document nodes.
+ : @param $string Input to be unquoted.
+ : @return an XML document node.
+ :)
+declare function impl:unquote($string as xs:string)
+ as document-node()
+{
+ xdmp:unquote($string)
+};
+
+
+(:~
+ : Parses a string as XML, returning one or more document nodes.
+ : @param $string Input to be unquoted.
+ : @return an XML document node.
+ :)
+declare function impl:quote($node as node())
+ as xs:string
+{
+ xdmp:quote($node)
+};
+
+
+
+(:~
+ : Creates the HTTP Request options XML fragment
+ : @param $accept the HTTP Accept header content-type.
+ : @return options element
+ :)
+declare function impl:build-request-options($request as element(http:request))
+ as element(xhttp:options)
+{
+ &lt;options xmlns="xdmp:http"&gt;
+ &lt;headers&gt;{
+ for $header in $request//http:header
+ return
+ element {QName('xdmp:http', string($header/@name))} {text {string($header/@value)}}
+ }&lt;/headers&gt;
+ &lt;format xmlns="xdmp:document-get"&gt;text&lt;/format&gt;
+ {
+ if (exists($request/http:body)) then
+ &lt;data xmlns="xdmp:http"&gt;{xdmp:quote($request/http:body/*)}&lt;/data&gt;
+ else
+ ()
+ }
+ &lt;/options&gt;
+};
+
+
+(:~
+ : Extract the head of the HTTP resonse data.
+ : @param $response
+ : @return the head of the HTTP response data.
+ :)
+declare function impl:get-response-head($response as item()*)
+ as element(xhttp:response)
+{
+ subsequence($response, 1, 1)
+};
+
+
+(:~
+ : Extract the body of the HTTP resonse data.
+ : @param $response
+ : @return a sequence of zero or more HTTP response body items.
+ :)
+declare function impl:get-response-body($response as item()*)
+ as item()?
+{
+ try {
+ xdmp:unquote(subsequence($response, 2))
+ } catch ($e) {
+ subsequence($response, 2, 1)
+ }
+};
+
+</pre></div><br/><div class="footer"><p style="text-align:right"><i/> |
+ generated by xquerydoc <a href="https://github.com/xquery/xquerydoc" target="xquerydoc">https://github.com/xquery/xquerydoc</a></p></div></div><script type="application/javascript">
+ window.onload = function(){ prettyPrint(); }
+ </script></body></html>
239 docs/api/md/xqdoc_xquery_lib-spq.xqy.html
View
@@ -0,0 +1,239 @@
+<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta http-equiv="Generator" content="xquerydoc - https://github.com/xquery/xquerydoc"/><title>xqDoc - </title><style type="text/css">
+ body {
+ font-family: Helvetica;
+ padding: 0.5em 1em;
+ }
+ pre {
+ font-family: Inconsolata, Consolas, monospace;
+ }
+ ol.results {
+ padding-left: 0;
+ }
+ .footer {
+ text-align:right;
+ border-top: solid 4px;
+ padding: 0.25em 0.5em;
+ font-size: 85%;
+ color: #999;
+ }
+ li.result {
+ list-style-position: inside;
+ list-style: none;
+ height:140px;
+ }
+ h2 {
+ display: inline-block;
+ margin: 0;
+ }
+
+ h2 a,
+ .result h3 a {
+ text-decoration: inherit;
+ color: inherit;
+ }
+ h3{
+ font-size: 140%;
+ background-color: #aaa;
+ border-bottom: 1px solid #000;
+ width: 100%;
+ }
+ h4{
+ font-size: 100%;
+ background-color: #ddd;
+ width: 90%;
+ }
+
+ .namespace {
+ color: #999;
+ }
+ .namespace:before {
+ content: "{";
+ }
+ .namespace:after {
+ content: "}";
+ }
+ table{
+ width:75%;
+ float:right;
+ }
+ td {
+ height:100px;
+ width:50%;
+ vertical-align:text-top;
+ }
+ </style><script src="lib/prettify.js" type="text/javascript"> </script><script src="lib/lang-xq.js" type="text/javascript"> </script><link rel="stylesheet" type="text/css" href="lib/prettify.css"/></head><body class="home"><div id="main"><h1><span class="namespace">http://www.w3.org/TR/sparql11-protocol/</span>  library module </h1><div id="variables"><h3>Variables</h3><div id="var_SPARQL_RESULTS_XML"><h4><pre class="prettyprint lang-xq"><u>Variable</u>: $SPARQL_RESULTS_XML as xs:string</pre></h4><p>Request encodings.</p></div><div id="var_RDF_XML"><h4><pre class="prettyprint lang-xq"><u>Variable</u>: $RDF_XML as xs:string</pre></h4></div><div id="var_USER_AGENT"><h4><pre class="prettyprint lang-xq"><u>Variable</u>: $USER_AGENT as xs:string</pre></h4><p>User-agent string.</p></div></div><div id="functions"><h3>Functions</h3><div id="func_spq_query-get_4"><h4><pre class="prettyprint lang-xq"><u>Function</u>: spq:query-get($endPointURI as xs:string,
+ $defaultGraphURIs as xs:string*, $namedGraphURIs as xs:string*,
+ $query as xs:string
+) as element(http:response)</pre></h4><p>The HTTP GET binding for query operation. Assumes the default Accept header for the SPARQL XML Results format.</p><h5>Params</h5><ul><li>endPointURI as xs:string the URL of the target SPARQL end-point.</li><li>defaultGraphURIs as xs:string* the default graph URIs</li><li>namedGraphURIs as xs:string* the named graph URIs</li><li>query as xs:string the SPARQL query to be sent.</li></ul><h5>Returns</h5><ul><li> element(http:response): the query response wrapped in an query-result element that carries the response content type.</li></ul></div><div id="func_spq_query-get_5"><h4><pre class="prettyprint lang-xq"><u>Function</u>: spq:query-get($endPointURI as xs:string,
+ $defaultGraphURIs as xs:string*, $namedGraphURIs as xs:string*,
+ $mediaType as xs:string, $query as xs:string
+) as element(http:response)</pre></h4><p>The HTTP GET binding for query operation.</p><h5>Params</h5><ul><li>endPointURI as xs:string the URL of the target SPARQL end-point.</li><li>defaultGraphURIs as xs:string* the default graph URIs</li><li>namedGraphURIs as xs:string* the named graph URIs</li><li>mediaType as xs:string the Media MIME-Type for the HTTP accept header.</li><li>query as xs:string the SPARQL query to be sent.</li></ul><h5>Returns</h5><ul><li> element(http:response): the query response wrapped in an query-result element that carries the response content type.</li></ul></div><div id="func_spq_query-post_4"><h4><pre class="prettyprint lang-xq"><u>Function</u>: spq:query-post($endPointURI as xs:string,
+ $defaultGraphURIs as xs:string*,
+ $namedGraphURIs as xs:string*, $query as xs:string
+) as element(http:response)</pre></h4><p>The HTTP GET binding for query operation. Assumes the default Accept header for the SPARQL XML Results format.</p><h5>Params</h5><ul><li>endPointURI as xs:string the URL of the target SPARQL end-point.</li><li>defaultGraphURIs as xs:string* the default graph URIs</li><li>namedGraphURIs as xs:string* the named graph URIs</li><li>query as xs:string the SPARQL query to be sent.</li></ul><h5>Returns</h5><ul><li> element(http:response): the query response wrapped in an query-result element that carries the response content type.</li></ul></div><div id="func_spq_query-post_5"><h4><pre class="prettyprint lang-xq"><u>Function</u>: spq:query-post($endPointURI as xs:string,
+ $defaultGraphURIs as xs:string*, $namedGraphURIs as xs:string*,
+ $mediaType as xs:string, $query as xs:string
+) as element(http:response)</pre></h4><p>The HTTP GET binding for query operation. Assumes the default Accept header for the SPARQL XML Results format.</p><h5>Params</h5><ul><li>endPointURI as xs:string the URL of the target SPARQL end-point.</li><li>defaultGraphURIs as xs:string* the default graph URIs</li><li>namedGraphURIs as xs:string* the named graph URIs</li><li>mediaType as xs:string the Media MIME-Type for the HTTP accept header.</li><li>query as xs:string the SPARQL query to be sent.</li></ul><h5>Returns</h5><ul><li> element(http:response): the query response wrapped in an query-result element that carries the response content type.</li></ul></div><div id="func_spq_submission_6"><h4><pre class="prettyprint lang-xq"><u>Function</u>: spq:submission($method as xs:string, $endpoitURI as xs:string, $defaultGraphURIs as xs:string*,
+ $namedGraphURIs as xs:string*, $mediaType as xs:string, $query as item()?
+) as
+ element(http:request)</pre></h4><p>Builds an XML fragment that carries the request details.</p><h5>Params</h5><ul><li>method as xs:string HTTP method (GET|POST)</li><li>endpoitURI as xs:string</li><li>defaultGraphURIs as xs:string* the default graph URIs</li><li>namedGraphURIs as xs:string* the named graph URIs</li><li>mediaType as xs:string Media MIME-Type for the HTTP accpet header</li><li>query as item()? An RDF graph.</li></ul><h5>Returns</h5><ul><li>
+ element(http:request): the HTTP request XML fragment.</li></ul></div></div><div><h3>Original Source Code</h3><pre class="prettyprint lang-xq">xquery version "1.0" encoding "utf-8";
+
+(:
+ : Licensed under the Apache License, Version 2.0 (the "License");
+ : you may not use this file except in compliance with the License.
+ : You may obtain a copy of the License at
+ :
+ : http://www.apache.org/licenses/LICENSE-2.0
+ :
+ : Unless required by applicable law or agreed to in writing, software
+ : distributed under the License is distributed on an "AS IS" BASIS,
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ : See the License for the specific language governing permissions and
+ : limitations under the License.
+ :)
+
+(:~
+ : This library provides functions for querying RDF Graph Stores
+ : that implement the W3C's SPARQL Protocol:
+ : &lt;http://www.w3.org/TR/sparql11-protocol/&gt;
+ : @author Philip A. R. Fennell
+ :)
+
+module namespace spq = "http://www.w3.org/TR/sparql11-protocol/";
+
+import module namespace impl = "http://www.marklogic.com/http" at
+ "lib-ml.xqy";
+
+declare namespace http = "http://www.w3.org/Protocols/rfc2616";
+declare namespace sr = "http://www.w3.org/2005/sparql-results#";
+
+declare default function namespace "http://www.w3.org/2005/xpath-functions";
+
+(:~ Request encodings. :)
+declare variable $SPARQL_RESULTS_XML as xs:string := "application/sparql-results+xml";
+declare variable $RDF_XML as xs:string := "application/rdf+xml";
+
+(:~ User-agent string. :)
+declare variable $USER_AGENT as xs:string := "xqy-sparql-protocol-client/0.3";
+
+
+(:~
+ : The HTTP GET binding for query operation. Assumes the default Accept header
+ : for the SPARQL XML Results format.
+ : @param $endPointURI the URL of the target SPARQL end-point.
+ : @param $defaultGraphURIs the default graph URIs
+ : @param $namedGraphURIs the named graph URIs
+ : @param $query the SPARQL query to be sent.
+ : @return the query response wrapped in an query-result element that carries
+ : the response content type.
+ :)
+declare function spq:query-get($endPointURI as xs:string,
+ $defaultGraphURIs as xs:string*, $namedGraphURIs as xs:string*,
+ $query as xs:string)
+ as element(http:response)
+{
+ spq:query-get($endPointURI, $defaultGraphURIs, $namedGraphURIs,
+ $SPARQL_RESULTS_XML, $query)
+};
+
+
+(:~
+ : The HTTP GET binding for query operation.
+ : @param $endPointURI the URL of the target SPARQL end-point.
+ : @param $defaultGraphURIs the default graph URIs
+ : @param $namedGraphURIs the named graph URIs
+ : @param $mediaType the Media MIME-Type for the HTTP accept header.
+ : @param $query the SPARQL query to be sent.
+ : @return the query response wrapped in an query-result element that carries
+ : the response content type.
+ :)
+declare function spq:query-get($endPointURI as xs:string,
+ $defaultGraphURIs as xs:string*, $namedGraphURIs as xs:string*,
+ $mediaType as xs:string, $query as xs:string)
+ as element(http:response)
+{
+ impl:normalise-response(
+ impl:http-request(
+ spq:submission('GET', $endPointURI, $defaultGraphURIs,
+ $namedGraphURIs, $mediaType, $query))
+ )
+};
+
+
+(:~
+ : The HTTP GET binding for query operation. Assumes the default Accept header
+ : for the SPARQL XML Results format.
+ : @param $endPointURI the URL of the target SPARQL end-point.
+ : @param $defaultGraphURIs the default graph URIs
+ : @param $namedGraphURIs the named graph URIs
+ : @param $query the SPARQL query to be sent.
+ : @return the query response wrapped in an query-result element that carries
+ : the response content type.
+ :)
+declare function spq:query-post($endPointURI as xs:string,
+ $defaultGraphURIs as xs:string*,
+ $namedGraphURIs as xs:string*, $query as xs:string)
+ as element(http:response)
+{
+ spq:query-post($endPointURI, $defaultGraphURIs, $namedGraphURIs,
+ $SPARQL_RESULTS_XML, $query)
+};
+
+
+(:~
+ : The HTTP GET binding for query operation. Assumes the default Accept header
+ : for the SPARQL XML Results format.
+ : @param $endPointURI the URL of the target SPARQL end-point.
+ : @param $defaultGraphURIs the default graph URIs
+ : @param $namedGraphURIs the named graph URIs
+ : @param $mediaType the Media MIME-Type for the HTTP accept header.
+ : @param $query the SPARQL query to be sent.
+ : @return the query response wrapped in an query-result element that carries
+ : the response content type.
+ :)
+declare function spq:query-post($endPointURI as xs:string,
+ $defaultGraphURIs as xs:string*, $namedGraphURIs as xs:string*,
+ $mediaType as xs:string, $query as xs:string)
+ as element(http:response)
+{
+ impl:normalise-response(
+ impl:http-request(
+ spq:submission('POST', $endPointURI, $defaultGraphURIs,
+ $namedGraphURIs, $mediaType, $query))
+ )
+};
+
+
+(:~
+ : Builds an XML fragment that carries the request details.
+ : @param $method HTTP method (GET|POST)
+ : @param $endPointURI the URL of the target Graph Store end-point.
+ : @param $defaultGraphURIs the default graph URIs
+ : @param $namedGraphURIs the named graph URIs
+ : @param $mediaType Media MIME-Type for the HTTP accpet header
+ : @param $query An RDF graph.
+ : @return the HTTP request XML fragment.
+ :)
+declare function spq:submission($method as xs:string, $endpoitURI as xs:string, $defaultGraphURIs as xs:string*,
+ $namedGraphURIs as xs:string*, $mediaType as xs:string, $query as item()?) as
+ element(http:request)
+{
+ let $queryParam as xs:string := concat('query=', encode-for-uri($query))
+ let $defaultGraphUriParams as xs:string* := for $uri in $defaultGraphURIs return concat('default=', $uri)
+ let $namedGraphUriParams as xs:string* := for $uri in $namedGraphURIs return concat('graph=', $uri)
+ let $requestParams as xs:string :=
+ concat('?', string-join(($queryParam, $defaultGraphUriParams, $namedGraphUriParams), '&amp;amp;'))
+ return
+ &lt;request xmlns="http://www.w3.org/Protocols/rfc2616" method="{$method}"
+ href="{concat($endpoitURI, if (exists($requestParams)) then $requestParams else '')}"&gt;
+ &lt;header name="accept" value="{$mediaType}"/&gt;
+ &lt;header name="user-agent" value="{$USER_AGENT}"/&gt;
+ &lt;header name="content-type" value="application/x-www-form-urlencoded"/&gt;
+ &lt;header name="encoding" value="UTF-8"/&gt;
+ &lt;/request&gt;
+};
+</pre></div><br/><div class="footer"><p style="text-align:right"><i/> |
+ generated by xquerydoc <a href="https://github.com/xquery/xquerydoc" target="xquerydoc">https://github.com/xquery/xquerydoc</a></p></div></div><script type="application/javascript">
+ window.onload = function(){ prettyPrint(); }
+ </script></body></html>
Please sign in to comment.
Something went wrong with that request. Please try again.