Implemented pass-through CQL-to-PQF conversions. Bug #861.
authorAdam Dickmeiss <adam@indexdata.dk>
Wed, 7 Feb 2007 13:36:57 +0000 (13:36 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Wed, 7 Feb 2007 13:36:57 +0000 (13:36 +0000)
NEWS
etc/Makefile.am
etc/cqlpass.properties [new file with mode: 0644]
src/cqltransform.c

diff --git a/NEWS b/NEWS
index 9db4d91..e710d9c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+Implemented pass-through CQL-to-PQF conversions. Bug #861.
+
 Fixed bug #832: Problem with MARC/charset in yaz-client.
 
 Fixed bug #668: save command line history for yaz-client.
index c32b16d..d2febf7 100644 (file)
@@ -1,8 +1,9 @@
-# $Id: Makefile.am,v 1.4 2005-12-16 15:01:25 adam Exp $
+# $Id: Makefile.am,v 1.5 2007-02-07 13:36:58 adam Exp $
 
 etcdatadir = $(pkgdatadir)/etc
 etcdata_DATA =  \
  pqf.properties \
+ cqlpass.properties \
  yazgfs.xml \
  maps.xml \
  MARC21slim2DC.xsl \
diff --git a/etc/cqlpass.properties b/etc/cqlpass.properties
new file mode 100644 (file)
index 0000000..d5e6c2a
--- /dev/null
@@ -0,0 +1,93 @@
+# $Id: cqlpass.properties,v 1.1 2007-02-07 13:36:58 adam Exp $
+# Properties for pass-through index name to Bib-1 use attribute
+# Requires YAZ 2.1.49 or later.
+
+# Identifiers for prefixes used in this file. (index.*)
+set.cql                = info:srw/cql-context-set/1/cql-v1.1
+set.pass       = http://indexdata.dk/yaz/cqlpass
+
+# The default set when an index doesn't specify one: Dublin Core
+set            = http://indexdata.dk/yaz/cqlpass
+
+# The default index when none is specified by the query
+index.cql.serverChoice                 = 1=1016
+
+index.pass.*                           = 1=*
+
+# Relation attributes are selected according to the CQL relation by
+# looking up the "relation.<relation>" property:
+#
+relation.<                             = 2=1
+relation.le                            = 2=2
+relation.eq                            = 2=3
+relation.exact                         = 2=3
+relation.ge                            = 2=4
+relation.>                             = 2=5
+relation.<>                            = 2=6
+
+# These two are what Zebra uses -- may not work on other servers
+relation.all                           = 4=6
+relation.any                           = 4=105
+
+# BIB-1 doesn't have a server choice relation, so we just make the
+# choice here, and use equality (which is clearly correct).
+relation.scr                           = 2=3
+
+# Relation modifiers.
+#
+relationModifier.relevant              = 2=102
+relationModifier.fuzzy                 = 5=103
+       ### truncation=regExpr-2 (5=103) in Zebra is "fuzzy matching"
+relationModifier.stem                  = 2=101
+relationModifier.phonetic              = 2=100
+
+# Non-standard extensions to provoke Zebra's inline sorting
+relationModifier.sort                  = 7=1
+relationModifier.sort-desc             = 7=2
+relationModifier.numeric               = 4=109
+
+# Position attributes may be specified for anchored terms (those
+# beginning with "^", which is stripped) and unanchored (those not
+# beginning with "^").  This may change when we get a BIB-1 truncation
+# attribute that says "do what CQL does".
+#
+position.first                         = 3=1 6=1
+       # "first in field"
+position.any                           = 3=3 6=1
+       # "any position in field"
+position.last                          = 3=4 6=1
+       # not a standard BIB-1 attribute
+position.firstAndLast                  = 3=3 6=3
+       # search term is anchored to be complete field
+
+# Structure attributes may be specified for individual relations; a
+# default structure attribute my be specified by the pseudo-relation
+# "*", to be used whenever a relation not listed here occurs.
+#
+structure.exact                                = 4=108
+       # string
+structure.all                          = 4=2
+structure.any                          = 4=2
+structure.*                            = 4=1
+       # phrase
+
+# Truncation attributes used to implement CQL wildcard patterns.  The
+# simpler forms, left, right- and both-truncation will be used for the
+# simplest patterns, so that we produce PQF queries that conform more
+# closely to the Bath Profile.  However, when a more complex pattern
+# such as "foo*bar" is used, we fall back on Z39.58-style masking.
+#
+truncation.right                       = 5=1
+truncation.left                                = 5=2
+truncation.both                                = 5=3
+truncation.none                                = 5=100
+truncation.regexp                      = 5=102
+truncation.z3958                       = 5=104
+
+# Finally, any additional attributes that should always be included
+# with each term can be specified in the "always" property.
+#
+always                                 = 6=1
+# 6=1: completeness = incomplete subfield
+
+
index 2c64c32..5cb26cb 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: cqltransform.c,v 1.26 2007-01-03 08:42:15 adam Exp $
+/* $Id: cqltransform.c,v 1.27 2007-02-07 13:36:58 adam Exp $
    Copyright (C) 1995-2007, Index Data ApS
    Index Data Aps
 
@@ -195,6 +195,7 @@ int cql_pr_attr_uri(cql_transform_t ct, const char *category,
         const char *cp0 = res, *cp1;
         while ((cp1 = strchr(cp0, '=')))
         {
+            int i;
             while (*cp1 && *cp1 != ' ')
                 cp1++;
             if (cp1 - cp0 >= sizeof(buf))
@@ -202,7 +203,19 @@ int cql_pr_attr_uri(cql_transform_t ct, const char *category,
             memcpy (buf, cp0, cp1 - cp0);
             buf[cp1-cp0] = 0;
             (*pr)("@attr ", client_data);
-            (*pr)(buf, client_data);
+
+            for (i = 0; buf[i]; i++)
+            {
+                if (buf[i] == '*')
+                    (*pr)(eval, client_data);
+                else
+                {
+                    char tmp[2];
+                    tmp[0] = buf[i];
+                    tmp[1] = '\0';
+                    (*pr)(tmp, client_data);
+                }
+            }
             (*pr)(" ", client_data);
             cp0 = cp1;
             while (*cp0 == ' ')