enable querying of an RDF file
VladimirAlexiev opened this issue · 4 comments
sparql-mode queries SPARQL endpoints that is specified with variables like this;
(setq
sparql-default-base-url "..." ;; org-babel-execute:sparql gets endpoint from param :url
sparql-prompt-base-url t ; this really means endpoint
sparql-default-format "text/csv" ;; org-babel-execute:sparql gets from param :format
)
(put 'sparql-base-url 'safe-local-variable 'stringp)
However, it's also interesting to query an RDF file. Eg during development of an ontology, you can extract the class hierarchy this way.
Two tools that allow this:
We could use advice
but it's better to fork sparql-mode
and add this and other additions (eg sparql vs update vs tarql
derived modes, syntax checking with flycheck, etc.
A crucial question is how to pass org-babel parameters to the query tool (see params :url
and :format
in the first code block).
I'm not sure whether I understand completely. With the variant org-babel-execute:sparql
in ELOT, :url
is reused for a filename (in the sense of, if it doesn't look like a url, assume it's a filename). Maybe this should be required to be a file:///
url? It appears to me to make sense that we don't need another header parameter, but can reuse :url
.
Regarding :format
, there's a use of this in the ELOT elot-robot-execute-query
to request either csv or ttl from ROBOT. Should that be done differently?
Hi @johanwk !
- you're using
:format
correctly but sparql-mode currently has only tabular SPARQL formats: #77 - I think guessing whether
:url
is an endpoint or a file is wrong.- Loading a file from http or https is a fully valid use case
- I think that both arq.query and robot query support loading multiple files (arq can take
--data
multiple times, haven't checked whether robot can take--input
multiple times) - Both allow loading data in named graphs: arq through
--namedGraph
, robot in a more involved way - The arq documentation is poor,
arq --help
shows more info but still raises some questions: apache/jena#2411
So I think you should use a new keyword eg :data
(which is a file in a triple or quad format, i.e. can populate multiple graphs).
In the future we may think of exploiting the namedGraph options of arq or robot.
Please reopen johanwk/elot#27
I can only say I agree with all of your points here. I chose shortcuts in order to progress ELOT. sparql-mode should do much better, I just don't want to wait for it.
Will reopen :)