From: Adam Dickmeiss Date: Wed, 5 Jul 2006 14:50:16 +0000 (+0000) Subject: Changed cql2pqf transformation to use a different evaluation order. X-Git-Tag: YAZ.2.1.26~47 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=8396cd72b6ca7b7154c1df50492fc0dfd004aad5;p=yaz-moved-to-github.git Changed cql2pqf transformation to use a different evaluation order. The new order is: always, relation, structure, position, truncation, index and relationModifier. Old order was: always, relation, relationModifier, structure, index, position, truncation. Note that the the latter ones override former ones for identical attributes.. The new scheme means that it is possible to override any existing attribute with a relationModifier. And also that it is possible to override everything for the index rule (except the ones listed in relationModifier). No order is perfect but this one, we believe, covers more real cases.. The "always" should have been called "default", since the attributes there can be overridden with all the rest. --- diff --git a/src/cqltransform.c b/src/cqltransform.c index 8494046..77236b9 100644 --- a/src/cqltransform.c +++ b/src/cqltransform.c @@ -1,4 +1,4 @@ -/* $Id: cqltransform.c,v 1.22 2006-04-05 12:04:51 mike Exp $ +/* $Id: cqltransform.c,v 1.23 2006-07-05 14:50:16 adam Exp $ Copyright (C) 1995-2005, Index Data ApS Index Data Aps @@ -10,8 +10,19 @@ See the file LICENSE. /** * \file cqltransform.c * \brief Implements CQL transform (CQL to RPN conversion). + * + * Evaluation order of rules: + * + * always + * relation + * structure + * position + * truncation + * index + * relationModifier */ +#include #include #include #include @@ -318,11 +329,16 @@ static const char *wcchar(const char *term, int length) void emit_term(cql_transform_t ct, + struct cql_node *cn, const char *term, int length, void (*pr)(const char *buf, void *client_data), void *client_data) { int i; + const char *ns = cn->u.st.index_uri; + + assert(cn->which == CQL_NODE_ST); + if (length > 0) { if (length > 1 && term[0] == '^' && term[length-1] == '^') @@ -410,6 +426,20 @@ void emit_term(cql_transform_t ct, pr, client_data, 0); } } + if (ns) { + cql_pr_attr_uri(ct, "index", ns, + cn->u.st.index, "serverChoice", + pr, client_data, 16); + } + if (cn->u.st.modifiers) + { + struct cql_node *mod = cn->u.st.modifiers; + for (; mod; mod = mod->u.st.modifiers) + { + cql_pr_attr(ct, "relationModifier", mod->u.st.index, 0, + pr, client_data, 20); + } + } (*pr)("\"", client_data); for (i = 0; iu.st.relation, "eq", pr, client_data, 19); - if (cn->u.st.modifiers) - { - struct cql_node *mod = cn->u.st.modifiers; - for (; mod; mod = mod->u.st.modifiers) - { - cql_pr_attr(ct, "relationModifier", mod->u.st.index, 0, - pr, client_data, 20); - } - } cql_pr_attr(ct, "structure", cn->u.st.relation, 0, pr, client_data, 24); - if (ns) { - cql_pr_attr_uri(ct, "index", ns, - cn->u.st.index, "serverChoice", - pr, client_data, 16); - } if (cn->u.st.relation && !cql_strcmp(cn->u.st.relation, "all")) { emit_wordlist(ct, cn, pr, client_data, "and"); @@ -527,7 +543,7 @@ void cql_transform_r(cql_transform_t ct, } else { - emit_term(ct, cn->u.st.term, strlen(cn->u.st.term), + emit_term(ct, cn, cn->u.st.term, strlen(cn->u.st.term), pr, client_data); } break;