X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Frpn2cql.c;h=b09d6a448318c2dd9c1c4143aa249b08dd7e00fd;hb=de94629a46584eafe114f740ed3000b26dd42ffb;hp=842d1a9b9c2ea0c49c58819f7af442e5e7c0fd21;hpb=d161ec774d6250a6814918f68559560d5c9db8cc;p=yaz-moved-to-github.git diff --git a/src/rpn2cql.c b/src/rpn2cql.c index 842d1a9..b09d6a4 100644 --- a/src/rpn2cql.c +++ b/src/rpn2cql.c @@ -20,7 +20,8 @@ #include #include /* For yaz_prox_unit_name() */ -static const char *lookup_index_from_string_attr(Z_AttributeList *attributes) +static const char *lookup_index_from_string_attr(Z_AttributeList *attributes, + Odr_int *numeric_value) { int j; int server_choice = 1; @@ -40,6 +41,10 @@ static const char *lookup_index_from_string_attr(Z_AttributeList *attributes) return son->u.string; } } + else if (ae->which == Z_AttributeValue_numeric) + { + *numeric_value = *ae->value.numeric; + } server_choice = 0; /* not serverChoice because we have use attr */ } } @@ -107,47 +112,47 @@ static int rpn2cql_attr(cql_transform_t ct, const char *index = cql_lookup_reverse(ct, "index.", attributes); const char *structure = cql_lookup_reverse(ct, "structure.", attributes); - /* if transform (properties) do not match, we'll just use a USE string attribute (bug #2978) */ + /* if transform (properties) do not match, we'll fall back + to string or report numeric attribute error */ if (!index) - index = lookup_index_from_string_attr(attributes); - - /* Attempt to fix bug #2978: Look for a relation attribute */ + { + Odr_int use_attribute = -1; + index = lookup_index_from_string_attr(attributes, &use_attribute); + if (!index) + { + wrbuf_rewind(w); + if (use_attribute != -1) + wrbuf_printf(w, ODR_INT_PRINTF, use_attribute); + return YAZ_BIB1_UNSUPP_USE_ATTRIBUTE; + } + } if (!relation) relation = lookup_relation_index_from_attr(attributes); - if (!index) - { - wrbuf_rewind(w); - return YAZ_BIB1_UNSUPP_USE_ATTRIBUTE; - } - /* for serverChoice we omit index+relation+structure */ - if (strcmp(index, "cql.serverChoice")) + if (!relation) + relation = "="; + else if (!strcmp(relation, "exact")) + relation = "=="; + else if (!strcmp(relation, "eq")) + relation = "="; + else if (!strcmp(relation, "le")) + relation = "<="; + else if (!strcmp(relation, "ge")) + relation = ">="; + + if (strcmp(index, "cql.serverChoice") || strcmp(relation, "=") + || (structure && strcmp(structure, "*"))) { wrbuf_puts(w, index); - if (relation) - { - if (!strcmp(relation, "exact")) - relation = "=="; - else if (!strcmp(relation, "eq")) - relation = "="; - else if (!strcmp(relation, "le")) - relation = "<="; - else if (!strcmp(relation, "ge")) - relation = ">="; - /* Missing mapping of not equal, phonetic, stem and relevance */ - wrbuf_puts(w, relation); - } - else - wrbuf_puts(w, "="); + wrbuf_puts(w, " "); + wrbuf_puts(w, relation); + wrbuf_puts(w, " "); - if (structure) + if (structure && strcmp(structure, "*")) { - if (strcmp(structure, "*")) - { - wrbuf_puts(w, "/"); - wrbuf_puts(w, structure); - wrbuf_puts(w, " "); - } + wrbuf_puts(w, "/"); + wrbuf_puts(w, structure); + wrbuf_puts(w, " "); } } return 0;