Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/yaz
authorMike Taylor <mike@miketaylor.org.uk>
Thu, 20 Aug 2009 08:16:05 +0000 (09:16 +0100)
committerMike Taylor <mike@miketaylor.org.uk>
Thu, 20 Aug 2009 08:16:05 +0000 (09:16 +0100)
doc/common
doc/yaz-marcdump-man.xml
include/yaz/marcdisp.h
include/yaz/prt-ext.h
src/cqltransform.c
src/marcdisp.c
src/prt-ext.c
src/rpn2cql.c
test/tst_rpn2cql.c
util/cql2pqf.c

index 5d3fcb2..cc80f24 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 5d3fcb2cd2ef1cf9c5c5b40ef5c5353913b56b4f
+Subproject commit cc80f24dcf550d033c2fdf29ea35b4e0961f357d
index b0807a6..51ebcfb 100644 (file)
   </refsect1>
  <refsect1><title>SEE ALSO</title>
   <para>
-   yaz(7)
-   yaz-iconv(1)
+   <citerefentry>
+    <refentrytitle>yaz</refentrytitle>
+    <manvolnum>7</manvolnum>
+   </citerefentry>
+  </para>
+  <para>
+   <citerefentry>
+    <refentrytitle>yaz-iconv</refentrytitle>
+    <manvolnum>1</manvolnum>
+   </citerefentry>
+  </para>
+  <para>
+   <ulink url="&url.marcxml;">MARCXML</ulink>.
+  </para>
+  <para>
+   <ulink url="&url.marcxchange;">ISO25577</ulink>.
   </para>
  </refsect1>
 </refentry>
index a63179f..ebc07b1 100644 (file)
@@ -65,7 +65,7 @@ YAZ_EXPORT void yaz_marc_xml(yaz_marc_t mt, int xmlmode);
 #define YAZ_MARC_MARCXML   3
 /** \brief Output format: ISO2709 */
 #define YAZ_MARC_ISO2709   4
-/** \brief Output format: MarcXchange */
+/** \brief Output format: MarcXchange (ISO25577) */
 #define YAZ_MARC_XCHANGE   5
 /** \brief Output format: check only (no marc output) */
 #define YAZ_MARC_CHECK  6
@@ -188,7 +188,7 @@ YAZ_EXPORT int yaz_marc_write_line(yaz_marc_t mt, WRBUF wrbuf);
 */
 YAZ_EXPORT int yaz_marc_write_marcxml(yaz_marc_t mt, WRBUF wrbuf);
 
-/** \brief writes record in MarcXchange XML
+/** \brief writes record in MarcXchange XML (ISO25577)
     \param mt handle
     \param wrbuf WRBUF for output
     \param format record format (e.g. "MARC21")
index e4b2f3f..be28a40 100644 (file)
@@ -92,6 +92,11 @@ struct Z_External
 #define Z_External_multisrch2 26
 #define Z_External_CQL 27
 #define Z_External_OCLCUserInfo 28
+#define Z_External_persistentResultSet 29
+#define Z_External_persistentQuery 30
+#define Z_External_periodicQuerySchedule 31
+#define Z_External_exportSpecification 32
+#define Z_External_exportInvocation 33
     union
     {
         /* Generic types */
@@ -131,6 +136,12 @@ struct Z_External
         Z_MultipleSearchTerms_2 *multipleSearchTerms_2;
         Z_InternationalString *cql;
         Z_OCLC_UserInformation *oclc;
+        Z_PRPersistentResultSet *persistentResultSet;
+
+        Z_PQueryPersistentQuery *persistentQuery;
+        Z_PQSPeriodicQuerySchedule *periodicQuerySchedule;
+        Z_ESExportSpecification *exportSpecification;
+        Z_EIExportInvocation *exportInvocation;
     } u;
 };
 
index 4036f60..1d75731 100644 (file)
@@ -350,7 +350,7 @@ const char *cql_lookup_reverse(cql_transform_t ct,
                     
             }
             if (i == e->attr_list.num_attributes)
-                return e->pattern;
+                return e->pattern + clen;
         }
     }
     return 0;
index 81f0afc..43a48f2 100644 (file)
@@ -713,7 +713,7 @@ int yaz_marc_write_marcxchange(yaz_marc_t mt, WRBUF wr,
                                const char *type)
 {
     return yaz_marc_write_marcxml_ns(mt, wr,
-                                     "http://www.bs.dk/standards/MarcXchange",
+                                     "info:lc/xmlns/marcxchange-v1",
                                      0, 0);
 }
 
index 4ccdc1b..3845209 100644 (file)
@@ -51,6 +51,11 @@ static Z_ext_typeent type_table[] =
     {{1, 2, 840, 10003, 8, 3,-1}, Z_External_acfKrb1, (Odr_fun) z_KRBObject},
     {{1, 2, 840, 10003, 10, 5,-1}, Z_External_multisrch2, (Odr_fun) z_MultipleSearchTerms_2},
     {{1, 2, 840, 10003, 16,  2, -1}, Z_External_CQL, (Odr_fun) z_InternationalString},
+    {{1, 2, 840, 10003, 9, 1,-1}, Z_External_persistentResultSet, (Odr_fun)z_PRPersistentResultSet},
+    {{1, 2, 840, 10003, 9, 2,-1}, Z_External_persistentQuery, (Odr_fun)z_PQueryPersistentQuery},
+    {{1, 2, 840, 10003, 9, 3,-1}, Z_External_periodicQuerySchedule, (Odr_fun)z_PQSPeriodicQuerySchedule},
+    {{1, 2, 840, 10003, 9, 6,-1}, Z_External_exportSpecification, (Odr_fun)z_ESExportSpecification},
+    {{1, 2, 840, 10003, 9, 7,-1}, Z_External_exportInvocation, (Odr_fun)z_EIExportInvocation},
     {{-1}, 0, 0}
 };
 
@@ -152,6 +157,17 @@ int z_External(ODR o, Z_External **p, int opt, const char *name)
          (Odr_fun)z_InternationalString, 0},
         {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_OCLCUserInfo,
          (Odr_fun)z_OCLC_UserInformation, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_persistentResultSet,
+         (Odr_fun)z_PRPersistentResultSet, 0},
+
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_persistentQuery,
+         (Odr_fun)z_PQueryPersistentQuery, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_periodicQuerySchedule,
+         (Odr_fun)z_PQSPeriodicQuerySchedule, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_exportSpecification,
+         (Odr_fun)z_ESExportSpecification, 0},
+        {ODR_EXPLICIT, ODR_CONTEXT, 0, Z_External_exportInvocation,
+         (Odr_fun)z_EIExportInvocation, 0},
         {-1, -1, -1, -1, 0, 0}
     };
 
index 692c55a..81ca550 100644 (file)
 #include <yaz/z-core.h>
 #include <yaz/wrbuf.h>
 
+static const char *lookup_index_from_string_attr(Z_AttributeList *attributes)
+{
+    int j;
+    int server_choice = 1;
+    for (j = 0; j < attributes->num_attributes; j++)
+    {
+        Z_AttributeElement *ae = attributes->attributes[j];
+        if (*ae->attributeType == 1) /* use attribute */
+        {
+            if (ae->which == Z_AttributeValue_complex)
+            {
+                Z_ComplexAttribute *ca = ae->value.complex;
+                int i;
+                for (i = 0; i < ca->num_list; i++)
+                {
+                    Z_StringOrNumeric *son = ca->list[i];
+                    if (son->which == Z_StringOrNumeric_string)
+                        return son->u.string;
+                }
+            }
+            server_choice = 0; /* not serverChoice because we have use attr */
+        }
+    }
+    if (server_choice)
+        return "cql.serverChoice";
+    return 0;
+}
+
 static int rpn2cql_attr(cql_transform_t ct,
                         Z_AttributeList *attributes, WRBUF w)
 {
     const char *relation = cql_lookup_reverse(ct, "relation.", attributes);
     const char *index = cql_lookup_reverse(ct, "index.", attributes);
     const char *structure = cql_lookup_reverse(ct, "structure.", attributes);
-    if (index && strcmp(index, "index.cql.serverChoice"))
+
+    /* if transform (properties) do not match, we'll just use a USE
+       string attribute (bug #2978) */
+    if (!index)
+        index = lookup_index_from_string_attr(attributes);
+
+    if (!index)
     {
-        wrbuf_puts(w, index+6);
+        cql_transform_set_error(ct,
+                                YAZ_BIB1_UNSUPP_USE_ATTRIBUTE, 0);
+        return -1;
+    }
+    /* for serverChoice we omit index+relation+structure */
+    if (strcmp(index, "cql.serverChoice"))
+    {
+        wrbuf_puts(w, index);
         if (relation)
         {
-            relation += 9;
-
             if (!strcmp(relation, "exact"))
                 relation = "==";
             else if (!strcmp(relation, "eq"))
@@ -46,7 +85,6 @@ static int rpn2cql_attr(cql_transform_t ct,
 
         if (structure)
         {
-            structure += 10;
             if (strcmp(structure, "*"))
             {
                 wrbuf_puts(w, "/");
index 34e6de2..8867ac9 100644 (file)
@@ -51,7 +51,8 @@ static void tst1(void)
     YAZ_CHECK(compare(ct, "abc", "abc"));
     YAZ_CHECK(compare(ct, "\"a b c\"", "\"a b c\""));
     YAZ_CHECK(compare(ct, "@and a b", "a and b"));
-    YAZ_CHECK(compare(ct, "@attr 1=4 abc", "abc"));
+    YAZ_CHECK(compare(ct, "@attr 1=field abc", "field=abc"));
+    YAZ_CHECK(compare(ct, "@attr 1=4 abc", 0)); /* should fail */
 
     cql_transform_define_pattern(ct, "index.title", "1=4");
     YAZ_CHECK(compare(ct, "@attr 1=4 abc", "title=abc"));
@@ -88,6 +89,7 @@ static void tst2(void)
     YAZ_CHECK(compare(ct, "@attr 1=30 @attr 2=4 1980", "dc.date>=1980"));
 
     YAZ_CHECK(compare(ct, "@attr 2=103 @attr 1=_ALLRECORDS 1", "cql.allRecords=1"));
+    YAZ_CHECK(compare(ct, "@attr 1=500 abc", 0));
     cql_transform_close(ct);
     wrbuf_destroy(w);
 }
index d5b2390..ba7c1a9 100644 (file)
@@ -48,7 +48,10 @@ int main(int argc, char **argv)
     }
     if (!fname)
         usage();
-    ct = cql_transform_open_fname(fname);
+    if (!strcmp(fname, "-"))
+        ct = cql_transform_create();
+    else
+        ct = cql_transform_open_fname(fname);
     if (!ct)
     {
         fprintf(stderr, "failed to read properties %s\n", fname);