Use YAZ backtrace facility PAZ-983
[pazpar2-moved-to-github.git] / src / charsets.c
index 9688628..61b6f19 100644 (file)
@@ -1,5 +1,5 @@
 /* This file is part of Pazpar2.
-   Copyright (C) 2006-2013 Index Data
+   Copyright (C) Index Data
 
 Pazpar2 is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
@@ -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;
@@ -203,15 +217,9 @@ pp2_charset_t pp2_charset_create_xml(xmlNode *xml_node)
 #if YAZ_HAVE_ICU
     UErrorCode status = U_ZERO_ERROR;
     struct icu_chain *chain = 0;
-    while (xml_node && xml_node->type != XML_ELEMENT_NODE)
-        xml_node = xml_node->next;
     chain = icu_chain_xml_config(xml_node, 1, &status);
-    if (!chain || U_FAILURE(status)){
-        //xmlDocPtr icu_doc = 0;
-        //xmlChar *xmlstr = 0;
-                //int size = 0;
-                //xmlDocDumpMemory(icu_doc, size);
-
+    if (!chain || U_FAILURE(status))
+    {
         yaz_log(YLOG_FATAL, "Could not parse ICU chain config:\n"
                 "<%s>\n ... \n</%s>",
                 xml_node->name, xml_node->name);