Allow deprecated ICU definitions again
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 7 Mar 2014 12:23:48 +0000 (13:23 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 7 Mar 2014 12:23:48 +0000 (13:23 +0100)
Partially reverts 77682ed3596450ab7b3caff707999d2f7977d614.

src/charsets.c
src/pazpar2_config.c
test/test_icu.cfg

index 32d5f4d..61b6f19 100644 (file)
@@ -173,6 +173,20 @@ int pp2_charset_fact_define(pp2_charset_fact_t pft,
     xmlChar *id = 0;
 
     assert(xml_node);
+
+    if (strcmp((const char *) xml_node->name, "icu_chain"))
+    {
+        yaz_log(YLOG_WARN, "Wrapper element <%s> deprecated", xml_node->name);
+        yaz_log(YLOG_LOG, "Use <icu_chain id=\"%s\">.. only", xml_node->name);
+        xml_node = xml_node->children;
+        while (xml_node && xml_node->type != XML_ELEMENT_NODE)
+            xml_node = xml_node->next;
+    }
+    if (!xml_node)
+    {
+        yaz_log(YLOG_FATAL, "Missing icu_chain element");
+        return -1;
+    }
     pct = pp2_charset_create_xml(xml_node);
     if (!pct)
         return -1;
index 4332397..0688b8e 100644 (file)
@@ -639,9 +639,14 @@ static struct conf_service *service_create_static(struct conf_server *server,
                  || !strcmp((const char *) n->name, "facet"))
 
         {
-            yaz_log(YLOG_FATAL, "No longer supported: <%s>", n->name);
-            yaz_log(YLOG_LOG, "Use <icu_chain id=\"%s\">.. instead", n->name);
-            return 0;
+            if (!service->charsets)
+                service->charsets = pp2_charset_fact_create();
+            if (pp2_charset_fact_define(service->charsets, n,
+                                        (const char *) n->name))
+            {
+                yaz_log(YLOG_FATAL, "ICU chain definition error");
+                return 0;
+            }
         }
         else if (!strcmp((const char *) n->name, (const char *) "metadata"))
         {
@@ -937,9 +942,14 @@ static struct conf_server *server_create(struct conf_config *config,
                  || !strcmp((const char *) n->name, "mergekey")
                  || !strcmp((const char *) n->name, "facet"))
         {
-            yaz_log(YLOG_FATAL, "No longer supported: <%s>", n->name);
-            yaz_log(YLOG_LOG, "Use <icu_chain id=\"%s\">.. instead", n->name);
-            return 0;
+            if (!server->charsets)
+                server->charsets = pp2_charset_fact_create();
+            if (pp2_charset_fact_define(server->charsets, n,
+                                        (const char *) n->name))
+            {
+                yaz_log(YLOG_FATAL, "ICU chain definition error");
+                return 0;
+            }
         }
         else if (!strcmp((const char *) n->name, "service"))
         {
index b51dafa..e3c1e89 100644 (file)
       <transform rule="[[:Control:][:WhiteSpace:][:Punctuation:]] Remove"/>
       <casemap rule="l"/>
     </icu_chain>
-    
-    <icu_chain id="mergekey" locale="en">
-      <tokenize rule="l"/>
-      <transform rule="[[:Control:][:WhiteSpace:][:Punctuation:]] Remove"/>
-      <casemap rule="l"/>
-    </icu_chain>
+
+    <mergekey><!-- the deprecated format -->    
+      <icu_chain locale="en">
+        <tokenize rule="l"/>
+        <transform rule="[[:Control:][:WhiteSpace:][:Punctuation:]] Remove"/>
+        <casemap rule="l"/>
+      </icu_chain>
+    </mergekey>
     
     <icu_chain id="facet" locale="en">
       <transliterate>[[:WhiteSpace:][,.!;]]* } [$] > ;</transliterate>