From a74de0cefd7999972739abb1e8a10b00d746b8ee Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Wed, 29 Apr 2015 12:54:28 +0200 Subject: [PATCH] Allow no element set name again When no element set is given, it will pick the first uri-line. If there's no uri-line it will use query of the matching db. --- src/filter_sparql.cpp | 4 ++-- src/sparql.c | 12 ++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/filter_sparql.cpp b/src/filter_sparql.cpp index 681575a..34759e5 100644 --- a/src/filter_sparql.cpp +++ b/src/filter_sparql.cpp @@ -426,13 +426,13 @@ Z_Records *yf::SPARQL::Session::fetch( for (; it != fset->results.end(); it++) { - if (schema && !strcmp(esn->u.generic, it->conf->schema.c_str())) - break; if (yaz_sparql_lookup_schema(it->conf->s, schema)) { uri_lookup = true; break; } + if (!schema || !strcmp(esn->u.generic, it->conf->schema.c_str())) + break; } if (it == fset->results.end()) { diff --git a/src/sparql.c b/src/sparql.c index e9987a1..50f41f6 100644 --- a/src/sparql.c +++ b/src/sparql.c @@ -378,11 +378,9 @@ int yaz_sparql_lookup_schema(yaz_sparql_t s, const char *schema) for (e = s->conf; e; e = e->next) { - if (!schema && !strcmp(e->pattern, "uri")) - break; - else if (schema && !strncmp(e->pattern, "uri.", 4)) + if (!strncmp(e->pattern, "uri.", 4)) { - if (!strcmp(e->pattern + 4, schema)) + if (!schema || !strcmp(e->pattern + 4, schema)) break; } } @@ -400,11 +398,9 @@ int yaz_sparql_from_uri_stream(yaz_sparql_t s, for (e = s->conf; e; e = e->next) { - if (!schema && !strcmp(e->pattern, "uri")) - break; - else if (schema && !strncmp(e->pattern, "uri.", 4)) + if (!strncmp(e->pattern, "uri.", 4)) { - if (!strcmp(e->pattern + 4, schema)) + if (!schema || !strcmp(e->pattern + 4, schema)) break; } } -- 1.7.10.4