From koffice-devel Fri Aug 20 18:44:23 2010 From: Jos van den Oever Date: Fri, 20 Aug 2010 18:44:23 +0000 To: koffice-devel Subject: RDF in KOffice: the need for context support in the soprano memory Message-Id: <201008202044.23798.jos.van.den.oever () kogmbh ! com> X-MARC-Message: https://marc.info/?l=koffice-devel&m=128232992326072 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_H0sbMAx6xnNREBL" --Boundary-00=_H0sbMAx6xnNREBL Content-Type: Text/Plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi all, These last days, I've been struggling with a problem in the KOffice RDF code. I wanted to fix the failing unit test and found that this was not so easy. I went to look for the cause of the problem and found that a query (run from the KWord SPARQL query form ;-) like this one: SELECT ?g ?s ?p ?o WHERE { GRAPH ?g { ?s ?p ?o } } would give no results, even though a query without GRAPH, like this: SELECT ?s ?p ?o WHERE { ?s ?p ?o } would work. Now these things used to work, so what has changed? The packages on my machine changed. KOffice uses Soprano for RDF support and Soprano uses Redland as the memory only backend. Testing a number of calls with the Redland command-line tools led me to this test: # create a graph with one statement in context 'c' rdfproc -c -n -s sqlite test add s p o c # query the graph rdfproc -c -s sqlite test query sparql - 'select ?g ?s ?p ?o where {graph ?g {?s ?p ?o}}' This should give one result line, but gives no result lines on some versions of Redland. Redland uses two other libraries: Raptor and Rasqal. The latter is responsible for doing the querying. Since verion 0.9.17 of Rasqal, a new query engine is in use. Starting from this version, the above commands give no results. The ChangeLog gives the option to compile Rasqal with --with-query-engine-version=1 to get the old query engine. This gives the desired behavior in Rasqal version 0.9.17, 0.9.18 and 0.9.19, but is not what e.g. Fedora Core 13 uses. I have reported the issue in the Redland bug database. http://bugs.librdf.org/mantis/view.php?id=382 Without support for GRAPH in queries, RDF in KOffice is dysfunctional. The Soprano backends are loaded dynamically, so I wrote a test to detect at runtime if Soprano can deliver the implementation we need. Best regards, Jos -- Jos van den Oever, software architect +49 391 25 19 15 53 http://kogmbh.com/legal/ --Boundary-00=_H0sbMAx6xnNREBL Content-Type: text/x-c++src; charset="UTF-8"; name="rasqaltest.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rasqaltest.cpp" #include #include #include #include #include int main() { /* Test whether a model is present that supports: - context / graphs - querying on graphs - storage in memory. */ const Soprano::Backend *backend = Soprano::discoverBackendByFeatures( Soprano::BackendFeatureContext | Soprano::BackendFeatureQuery | Soprano::BackendFeatureStorageMemory); if (backend == NULL) { // without a backend with the desired features, this test fails qDebug() << "No suitable backend found."; return 1; } qDebug() << "Found a backend: " << backend->pluginName(); Soprano::setUsedBackend(backend); Soprano::BackendSettings backendSettings; backendSettings << Soprano::BackendOptionStorageMemory; Soprano::StorageModel* model = backend->createModel(backendSettings); if (model == NULL) { // if model creation failed, this test fails qDebug() << "No model could be created."; return 1; } model->addStatement(Soprano::Statement( QUrl("subject"), QUrl("predicate"), QUrl("object"), QUrl("context"))); Soprano::QueryResultIterator it = model->executeQuery( "SELECT ?g ?s ?p ?o WHERE { GRAPH ?g { ?s ?p ?o } }", Soprano::Query::QueryLanguageSparql); if (!it.next()) { // there should be exactly one result statement qDebug() << "Query returned too few results."; delete model; return 1; } if (it.next()) { // there should be exactly one result statement qDebug() << "Query returned too many results."; delete model; return 1; } delete model; return 0; } --Boundary-00=_H0sbMAx6xnNREBL Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ koffice-devel mailing list koffice-devel@kde.org https://mail.kde.org/mailman/listinfo/koffice-devel --Boundary-00=_H0sbMAx6xnNREBL--