conf->uri = mp::xml::get_text(attr->children);
else if (!strcmp((const char *) attr->name, "schema"))
conf->schema = mp::xml::get_text(attr->children);
+ else if (!strcmp((const char *) attr->name, "include"))
+ {
+ std::string name = mp::xml::get_text(attr->children);
+ std::list<ConfPtr>::const_iterator it = db_conf.begin();
+ while (1)
+ if (it == db_conf.end())
+ {
+ throw mp::filter::FilterException(
+ "include db not found: " + name);
+ }
+ else if (name.compare((*it)->db) == 0)
+ {
+ yaz_sparql_include(s, (*it)->s);
+ break;
+ }
+ else
+ it++;
+ }
else
throw mp::filter::FilterException(
"Bad attribute " + std::string((const char *)
fset->db = db;
it = m_sparql->db_conf.begin();
for (; it != m_sparql->db_conf.end(); it++)
- if (yaz_match_glob((*it)->db.c_str(), db.c_str()))
+ if ((*it)->schema.length() > 0
+ && yaz_match_glob((*it)->db.c_str(), db.c_str()))
{
mp::wrbuf addinfo_wr;
mp::wrbuf sparql_wr;
nmem_destroy(s->nmem);
}
+void yaz_sparql_include(yaz_sparql_t s, yaz_sparql_t u)
+{
+ struct sparql_entry *e = u->conf;
+ for (; e; e = e->next)
+ yaz_sparql_add_pattern(s, e->pattern, e->value);
+}
+
int yaz_sparql_add_pattern(yaz_sparql_t s, const char *pattern,
const char *value)
{
YAZ_EXPORT
int yaz_sparql_lookup_schema(yaz_sparql_t s, const char *schema);
+YAZ_EXPORT
+void yaz_sparql_include(yaz_sparql_t s, yaz_sparql_t u);
+
YAZ_END_CDECL
#endif
static void tst2(void)
{
yaz_sparql_t s = yaz_sparql_create();
+ yaz_sparql_t s2 = yaz_sparql_create();
yaz_sparql_add_pattern(s, "prefix",
"rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns");
" OPTIONAL { ?inst bf:heldBy ?lib } .\n"
" ?work bf:creator/bf:label ?v0 "
"FILTER(contains(?v0, \"london\"))\n"
+
+
"}\n"));
+ yaz_sparql_include(s2, s);
+
YAZ_CHECK(test_query(
- s, "@or @and @attr 1=bf.creator a @attr 1=bf.title b @attr 1=bf.title c",
+ s2, "@or @and @attr 1=bf.creator a @attr 1=bf.title b @attr 1=bf.title c",
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns>\n"
"PREFIX bf: <http://bibframe.org/vocab/>\n"
"PREFIX gs: <http://gs.com/panorama/domain-model>\n"
"}\n"
));
+ yaz_sparql_destroy(s2);
yaz_sparql_destroy(s);
}