Liking cljdoc? Tell your friends :D

grafter-2.rdf4j.sparql

Functions for executing SPARQL queries with grafter RDF repositories, that support basic binding replacement etc.

Functions for executing SPARQL queries with grafter RDF
repositories, that support basic binding replacement etc.
raw docstring

ensure-sparql-fileclj

(ensure-sparql-file sparql-file)
source

queryclj

(query sparql-file)
(query sparql-file opts)
(query sparql-file repo)
(query sparql-file opts repo)
(query sparql-file bindings repo)
(query sparql-file opts bindings repo)

Takes a string reference to a sparql-file on the resource path and optionally a map of bindings that should map SPARQL variables from your query to concrete values, allowing you to restrict and customise your query.

The opts map is optional. Options include:

  • :reasoning? true|false whether or not reasoning/inference should be used in the query. DEFAULT: false

The bindings map is optional, and if it's not provided then the query in the file is run as is.

Additionally, if your sparql query specifies a LIMIT or OFFSET the bindings map supports the special keys ::limits and ::offsets. Which should be maps binding identifiable limits/offsets from your query to new values.

VALUES clause bindings are supported like normal ?var bindings when there is just one VALUES binding. When there are more than one, you should provide a vector containing the component var names as the key in the map, with a sequence of sequences as the values themselves. e.g. to override a clause like this:

VALUES ?a ?b { (1 2) (3 4) }

You would provide a map that looked like this:

{[:a :b] [[1 1] [2 2] [3 3]]}

nil's inside the VALUES row's themselves will raise an error.

The clojure keyword :grafter-2.rdf.sparql/undef can be used to represent a SPARQL UNDEF, in the bound VALUES data.

The final argument repo should be the repository to query.

If only one argument referencing a resource path to a SPARQL query then a partially applied function is returned. e.g.

(def spog (query "grafter/rdf/sparql/select-spog.sparql"))

(spog r) ;; ... triples ...

(spog r {:s [(URI. "http://s1") (URI. "http://s2")]}) ;; triples for VALUES clause subjects s.

(spog r {:s (java.net.URI. "http://example.org/data/a-triple")}) ;; triples for given subject s.

Takes a string reference to a `sparql-file` on the resource path and
optionally a map of bindings that should map SPARQL variables from your query
to concrete values, allowing you to restrict and customise your query.

The `opts` map is optional. Options include:

- `:reasoning?` `true|false` whether or not reasoning/inference should be used
in the query. DEFAULT: `false`

The `bindings` map is optional, and if it's not provided then the query in the
file is run as is.

Additionally, if your sparql query specifies a LIMIT or OFFSET the bindings
map supports the special keys ::limits and ::offsets.  Which should be maps
binding identifiable limits/offsets from your query to new values.

VALUES clause bindings are supported like normal ?var bindings when there is
just one VALUES binding.  When there are more than one, you should provide a
vector containing the component var names as the key in the map, with a
sequence of sequences as the values themselves.  e.g. to override a clause
like this:

VALUES ?a ?b { (1 2) (3 4) }

You would provide a map that looked like this:

{[:a :b] [[1 1] [2 2] [3 3]]}

nil's inside the VALUES row's themselves will raise an error.

The clojure keyword :grafter-2.rdf.sparql/undef can be used to represent a
SPARQL UNDEF, in the bound VALUES data.

The final argument `repo` should be the repository to query.

If only one argument referencing a resource path to a SPARQL query then a
partially applied function is returned. e.g.

(def spog (query "grafter/rdf/sparql/select-spog.sparql"))

(spog r) ;; ... triples ...

(spog r {:s [(URI. "http://s1") (URI. "http://s2")]}) ;; triples for VALUES clause subjects s.

(spog r {:s (java.net.URI. "http://example.org/data/a-triple")}) ;; triples for given subject s.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close