struct icu_chain_step * steps;
};
-struct icu_chain * icu_chain_create(const uint8_t * identifier,
+struct icu_chain * icu_chain_create( // const uint8_t * identifier,
const uint8_t * locale);
void icu_chain_destroy(struct icu_chain * chain);
-struct icu_chain * icu_chain_xml_config(xmlNode *xml_node,
+struct icu_chain * icu_chain_xml_config(xmlNode *xml_node,
+ const uint8_t * locale,
UErrorCode * status);
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: icu_I18N.c,v 1.4 2007-10-24 13:23:34 marc Exp $
+ * $Id: icu_I18N.c,v 1.5 2007-10-24 14:48:17 marc Exp $
*/
#if HAVE_CONFIG_H
-struct icu_chain * icu_chain_create(const uint8_t * identifier,
+struct icu_chain * icu_chain_create( //const uint8_t * identifier,
const uint8_t * locale)
{
struct icu_chain * chain
= (struct icu_chain *) malloc(sizeof(struct icu_chain));
- strncpy((char *) chain->identifier, (const char *) identifier, 128);
- chain->identifier[128 - 1] = '\0';
+ //strncpy((char *) chain->identifier, (const char *) identifier, 128);
+ //chain->identifier[128 - 1] = '\0';
strncpy((char *) chain->locale, (const char *) locale, 16);
chain->locale[16 - 1] = '\0';
struct icu_chain * icu_chain_xml_config(xmlNode *xml_node,
+ const uint8_t * locale,
UErrorCode * status){
xmlNode *node = 0;
if (!xml_node
||xml_node->type != XML_ELEMENT_NODE
- || strcmp((const char *) xml_node->name, "icu_chain"))
+ // || strcmp((const char *) xml_node->name, "icu_chain")
+ )
return 0;
- {
- xmlChar *xml_id = xmlGetProp(xml_node, (xmlChar *) "id");
- xmlChar *xml_locale = xmlGetProp(xml_node, (xmlChar *) "locale");
-
- if (!xml_id || !strlen((const char *) xml_id)
- || !xml_locale || !strlen((const char *) xml_locale))
- return 0;
-
- chain = icu_chain_create((const uint8_t *) xml_id,
- (const uint8_t *) xml_locale);
-
- xmlFree(xml_id);
- xmlFree(xml_locale);
- }
+ chain = icu_chain_create( // (const uint8_t *) xml_id,
+ locale);
+
if (!chain)
return 0;
+
for (node = xml_node->children; node; node = node->next)
{
-/* $Id: tst_icu_I18N.c,v 1.5 2007-10-24 13:23:34 marc Exp $
+/* $Id: tst_icu_I18N.c,v 1.6 2007-10-24 14:48:17 marc Exp $
Copyright (c) 2006-2007, Index Data.
This file is part of Pazpar2.
struct icu_chain * chain = 0;
- const char * xml_str = "<icu_chain id=\"en:word\" locale=\"en\">"
+ const char * xml_str = "<icu_chain>"
"<normalize rule=\"[:Control:] Any-Remove\"/>"
"<tokenize rule=\"l\"/>"
"<normalize rule=\"[[:WhiteSpace:][:Punctuation:]] Remove\"/>"
// printf("ICU chain:\ninput: '%s'\n", en_str);
- chain = icu_chain_xml_config(xml_node, &status);
+ chain = icu_chain_xml_config(xml_node, (uint8_t *) "en", &status);
#if 0
chain = icu_chain_create((uint8_t *) "en:word", (uint8_t *) "en");
UErrorCode status = U_ZERO_ERROR;
struct icu_chain * chain = 0;
- const char * xml_str = "<icu_chain id=\"en:word\" locale=\"en\">"
+ const char * xml_str = "<icu_chain>"
/* if the first rule is normalize instead. Then it works */
#if 0
xmlNode *xml_node = xmlDocGetRootElement(doc);
YAZ_CHECK(xml_node);
- chain = icu_chain_xml_config(xml_node, &status);
+ chain = icu_chain_xml_config(xml_node, (uint8_t *) "en", &status);
xmlFreeDoc(doc);
YAZ_CHECK(chain);
UErrorCode status = U_ZERO_ERROR;
struct icu_chain * chain = 0;
- const char * xml_str = "<icu_chain id=\"en:word\" locale=\"en\">"
+ const char * xml_str = "<icu_chain>"
"<tokenize rule=\"w\"/>"
"<normalize rule=\"[[:WhiteSpace:][:Punctuation:]] Remove\"/>"
"<index/>"
xmlNode *xml_node = xmlDocGetRootElement(doc);
YAZ_CHECK(xml_node);
- chain = icu_chain_xml_config(xml_node, &status);
+ chain = icu_chain_xml_config(xml_node, (uint8_t *) "en", &status);
xmlFreeDoc(doc);
YAZ_CHECK(chain);
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: yaz-icu.c,v 1.2 2007-10-22 17:32:08 adam Exp $
+ * $Id: yaz-icu.c,v 1.3 2007-10-24 14:48:18 marc Exp $
*/
#if HAVE_CONFIG_H
xmlDoc *doc = xmlParseFile(config.conffile);
xmlNode *xml_node = xmlDocGetRootElement(doc);
+ xmlChar *xml_locale = xmlGetProp(xml_node, (xmlChar *) "locale");
long unsigned int token_count = 0;
long unsigned int line_count = 0;
exit (1);
}
+ if (!xml_locale || !strlen((const char *) xml_locale))
+ return;
- config.chain = icu_chain_xml_config(xml_node, &status);
+ config.chain = icu_chain_xml_config(xml_node, (uint8_t *) "en", &status);
+
+ xmlFree(xml_locale);
+
if (config.chain && U_SUCCESS(status))
success = 1;
exit (1);
}
+
+
if (p_config->xmloutput)
fprintf(config.outfile,
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"