Functions to support interacting with a SPARQL endpoint.
See also https://www.w3.org/TR/sparql11-query
.
Functions to support interacting with a SPARQL endpoint. See also `https://www.w3.org/TR/sparql11-query`.
(angle-bracket-uri s)
returns <s
> if it matches the scheme for a URI, else returns s
.
returns <`s`> if it matches the scheme for a URI, else returns `s`.
A map with keys :uri :lang :datatype, each mapping to <translator> Where <translator> := (fn[var-value]) -> <translated value> <var-value> :={'value' <value> 'type' 'uri' | 'literal' ...maybe... 'xml:lang' <lang> (if literal) 'datatype' <datatype> (if literal) }
A map with keys :uri :lang :datatype, each mapping to <translator> Where <translator> := (fn[var-value]) -> <translated value> <var-value> :={'value' <value> 'type' 'uri' | 'literal' ...maybe... 'xml:lang' <lang> (if literal) 'datatype' <datatype> (if literal) }
(iri-for uri)
Returns an instance of org.apache.jena.iri.impl.IRIImpl
for uri
Where
<uri> a string, typically the 'value' value of a SELECT binding whose 'type'
value is 'uri'
NOTE: this does not seem to be a very mature class in Jena, and you may need
to poke around a bit to find methods that don't trigger NYI errors
Returns an instance of `org.apache.jena.iri.impl.IRIImpl` for `uri` Where <uri> a string, typically the 'value' value of a SELECT binding whose 'type' value is 'uri' NOTE: this does not seem to be a very mature class in Jena, and you may need to poke around a bit to find methods that don't trigger NYI errors
(parse-prologue query)
Returns [<base>, <uri-to-qname>, <qname-to-uri>] parsed from the
<prologue> to query
Where
<base> is a URI string for the base of <query> <uri-to-qname> := fn[<uri>] -> <quickname>, or <uri> if there was no matching prefix in <prolog> <qname-to-uri> := fn[<qname>] -> <uri> or <qname> if there was no matching prefix in <prologue> <uri> is typically a URI with a prefix defined in the <prologue>, but may be any string <qname> is typically a qname with a prefix defined in <prologue>, but may be any string <prologue> is the prologue parsed from <query>, for which see spex at `https://www.w3.org/TR/sparql11-query/`.
Returns [<base>, <uri-to-qname>, <qname-to-uri>] parsed from the <prologue> to `query` Where <base> is a URI string for the base of <query> <uri-to-qname> := fn[<uri>] -> <quickname>, or <uri> if there was no matching prefix in <prolog> <qname-to-uri> := fn[<qname>] -> <uri> or <qname> if there was no matching prefix in <prologue> <uri> is typically a URI with a prefix defined in the <prologue>, but may be any string <qname> is typically a qname with a prefix defined in <prologue>, but may be any string <prologue> is the prologue parsed from <query>, for which see spex at `https://www.w3.org/TR/sparql11-query/`.
(parse-xsd-value literal)
Returns <translated-value> for literal
Where
<literal> is a sparql binding value-map s.t.
{type literal, datatype <datatype>, value <value> ...}
<translated-value> is an instance of the xsd datatype associated with
<datatype> specified for <value>, or <value> if no translation can be
found.
<datatype> is a string indicating the datatype associated with <value>,
which may be an xsd datatype
Returns <translated-value> for `literal` Where <literal> is a sparql binding value-map s.t. {type literal, datatype <datatype>, value <value> ...} <translated-value> is an instance of the xsd datatype associated with <datatype> specified for <value>, or <value> if no translation can be found. <datatype> is a string indicating the datatype associated with <value>, which may be an xsd datatype
(simplifier-for-prologue query)
(simplifier-for-prologue query translators)
Returns a function (fn[<var-map>] -> {<var-keyword> <translated-value>, ...}
for each <var> in var-map
, transating URIs into qnames derived from the
prologue to query
, and otherwise using translators
(default
default-translators
)
Returns a function (fn[<var-map>] -> {<var-keyword> <translated-value>, ...} for each <var> in `var-map`, transating URIs into qnames derived from the prologue to `query`, and otherwise using `translators` (default `default-translators`)
(simplify var-map)
(simplify var-map translators)
Returns {<var-keyword> <translated-value>, ...} for each <var> in var-map
,
translated according to translators
(default default-translators
)
Where
<var-map> := {<var> <var-value>...}
<var> is a string typically corresponding to a variable in a SELECT query
<var-value> is a map with keys in the set #{type value xml:lang datatype},
per the SPARQL 1.1 specification for SELECT queries.
<var-keyword> is keyword corresponding to <var>
<translated-value> is <value> from <var-value>, translated using <translators>
<translators> is a map with keys in #{:uri :lang :datatype}, each of which
maps to a (fn[var-value])-> <translated-value>, depending on whether
<var-value> represents a URI, a literal with a language tag, or a literal
with a specified datatype. Default is simply to render the 'value' field.
Note: see also https://www.w3.org/TR/sparql11-results-json/
Returns {<var-keyword> <translated-value>, ...} for each <var> in `var-map`, translated according to `translators` (default `default-translators`) Where <var-map> := {<var> <var-value>...} <var> is a string typically corresponding to a variable in a SELECT query <var-value> is a map with keys in the set #{type value xml:lang datatype}, per the SPARQL 1.1 specification for SELECT queries. <var-keyword> is keyword corresponding to <var> <translated-value> is <value> from <var-value>, translated using <translators> <translators> is a map with keys in #{:uri :lang :datatype}, each of which maps to a (fn[var-value])-> <translated-value>, depending on whether <var-value> represents a URI, a literal with a language tag, or a literal with a specified datatype. Default is simply to render the 'value' field. Note: see also `https://www.w3.org/TR/sparql11-results-json/`
(sparql-ask endpoint query)
(sparql-ask endpoint query http-req)
Returns boolean value per query
posed to endpoint
, through an
HTTP call possibly informed by http-req
.
Where
<query> is a SPARQL ASK query
<endpoint> is a SPARQL endpoint
<http-req> := {<param> <spec>, ...}
<param> is anything described in `https://github.com/dakrone/clj-http` Though :form-params will be overridden.
Returns boolean value per `query` posed to `endpoint`, through an HTTP call possibly informed by `http-req`. Where <query> is a SPARQL ASK query <endpoint> is a SPARQL endpoint <http-req> := {<param> <spec>, ...} <param> is anything described in `https://github.com/dakrone/clj-http` Though :form-params will be overridden.
(sparql-construct endpoint query)
(sparql-construct endpoint query http-req)
Returns <expression> for query
posed to endpoint
, possibly informed
by http-req
Where
<query> := a SPARQL CONSTRUCT query
<endpoint> the URL string of a SPARQL endpoint
<http-req> := {?param...}
<param> is anything described in `https://github.com/dakrone/clj-http` Though :form-params will be overridden. The default :accept parameter is text/turtle.
Returns <expression> for `query` posed to `endpoint`, possibly informed by `http-req` Where <query> := a SPARQL CONSTRUCT query <endpoint> the URL string of a SPARQL endpoint <http-req> := {?param...} <param> is anything described in `https://github.com/dakrone/clj-http` Though :form-params will be overridden. The default :accept parameter is text/turtle.
(sparql-query endpoint query)
(sparql-query endpoint query http-req)
Returns output of <response-body> for SPARQL query
posed to endpoint
, possibly informed by http-req
Where
<response-body> is the body of the response to <query>, posed to <endpoint>
via an HTTP GET call which may be informed by <param>s in <http-req>
<http-req> := {<param> <spec>,...}, default is {}
<param> is anything described in <`https://github.com/dakrone/clj-http`> typically :debug or authentication parameters :query-params will be overridden. {:cookie-policy :standard} will be asserted by default
Returns output of <response-body> for SPARQL `query` posed to `endpoint`, possibly informed by `http-req` Where <response-body> is the body of the response to <query>, posed to <endpoint> via an HTTP GET call which may be informed by <param>s in <http-req> <http-req> := {<param> <spec>,...}, default is {} <param> is anything described in <`https://github.com/dakrone/clj-http`> typically :debug or authentication parameters :query-params will be overridden. {:cookie-policy :standard} will be asserted by default
(sparql-select endpoint query)
(sparql-select endpoint query http-req)
Returns <bindings> for query
posed to endpoint
, using an HTTP call
informed by http-req
Where
<query> := a SPARQL SELECT query
<endpoint> the URL string of a SPARQL endpoint
<bindings> := [<binding> , ...]
<binding> := {<var> <var-value>, ...}
<var> is a variable specified in <query>
<var-value> := <uri-value> or <literal-value>
<uri-value> := {type uri, value <uri>}
<literal-value> := {type literal,
value <value>,
maybe datatype <datatype>,
maybe xml:lang <lang>
}
Note: see also https://www.w3.org/TR/sparql11-results-json/
Returns <bindings> for `query` posed to `endpoint`, using an HTTP call informed by `http-req` Where <query> := a SPARQL SELECT query <endpoint> the URL string of a SPARQL endpoint <bindings> := [<binding> , ...] <binding> := {<var> <var-value>, ...} <var> is a variable specified in <query> <var-value> := <uri-value> or <literal-value> <uri-value> := {type uri, value <uri>} <literal-value> := {type literal, value <value>, maybe datatype <datatype>, maybe xml:lang <lang> } Note: see also `https://www.w3.org/TR/sparql11-results-json/`
(sparql-update endpoint update)
(sparql-update endpoint update http-req)
Side Effect: Modifies the contents of endpoint
per the update query
update
, possibly informed by http parameters http-req' Returns the string returned by
endpoint` if successful.
Where
<endpoint> is a SPARQL update endpoint
<update> is a SPARQL update expression
<http-req> := {?param...}
<param> is anything described in `https://github.com/dakrone/clj-http` Though :form-params will be overridden. This may be used for authentication parameters for example. Default parameters are {:cookie-policy :standard, :accept text/plain}
Side Effect: Modifies the contents of `endpoint` per the update query `update`, possibly informed by http parameters `http-req' Returns the string returned by `endpoint` if successful. Where <endpoint> is a SPARQL update endpoint <update> is a SPARQL update expression <http-req> := {?param...} <param> is anything described in `https://github.com/dakrone/clj-http` Though :form-params will be overridden. This may be used for authentication parameters for example. Default parameters are {:cookie-policy :standard, :accept text/plain}
Maps datatype names to xsd datatypes
Maps datatype names to xsd datatypes
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close