+ const char * xml_str = "<icu locale=\"en\">"
+ "<tokenize rule=\"w\"/>"
+ "<transform rule=\"[[:WhiteSpace:][:Punctuation:]] Remove\"/>"
+ "</icu>";
+
+ xmlDoc *doc = xmlParseMemory(xml_str, strlen(xml_str));
+ YAZ_CHECK(doc);
+ if (!doc)
+ return;
+ xml_node = xmlDocGetRootElement(doc);
+ YAZ_CHECK(xml_node);
+ if (!xml_node)
+ return ;
+
+ chain = icu_chain_xml_config(xml_node, 0, &status);
+
+ xmlFreeDoc(doc);
+ YAZ_CHECK(chain);
+
+ iter = icu_iter_create(chain);
+ icu_iter_first(iter, "a string with 15 tokens and 8 displays");
+ YAZ_CHECK(iter);
+ if (!iter)
+ return;
+ while (icu_iter_next(iter))
+ {
+ yaz_log(YLOG_LOG, "[%s]", icu_iter_get_norm(iter));
+ }
+ icu_iter_destroy(iter);
+ icu_chain_destroy(chain);
+}
+
+static int test_iter(struct icu_chain *chain, const char *input,
+ const char *expected)
+{
+ yaz_icu_iter_t iter = icu_iter_create(chain);
+ WRBUF result, second;
+ int success = 1;
+
+ if (!iter)
+ {
+ yaz_log(YLOG_WARN, "test_iter: input=%s !iter", input);
+ return 0;
+ }
+
+ if (icu_iter_next(iter))
+ {
+ yaz_log(YLOG_WARN, "test_iter: expecting 0 before icu_iter_first");
+ return 0;
+ }
+
+ result = wrbuf_alloc();
+ icu_iter_first(iter, input);
+ while (icu_iter_next(iter))
+ {
+ wrbuf_puts(result, "[");
+ wrbuf_puts(result, icu_iter_get_norm(iter));
+ wrbuf_puts(result, "]");
+ }
+
+ second = wrbuf_alloc();
+ icu_iter_first(iter, input);
+ while (icu_iter_next(iter))
+ {
+ wrbuf_puts(second, "[");
+ wrbuf_puts(second, icu_iter_get_norm(iter));
+ wrbuf_puts(second, "]");
+ }
+
+ icu_iter_destroy(iter);