+ chain = icu_chain_create((const uint8_t *) xml_id,
+ (const uint8_t *) xml_locale);
+
+ xmlFree(xml_id);
+ xmlFree(xml_locale);
+ if (!chain)
+ return 0;
+
+ for (node = xml_node->children; node; node = node->next)
+ {
+ xmlChar *xml_rule = 0;
+ struct icu_chain_step * step = 0;
+ if (node->type != XML_ELEMENT_NODE)
+ continue;
+
+ xml_rule = xmlGetProp(node, (xmlChar *) "rule");
+
+ if (!strcmp((const char *) node->name,
+ (const char *) "casemap")){
+ step = icu_chain_insert_step(chain, ICU_chain_step_type_casemap,
+ (const uint8_t *) xml_rule, status);
+ }
+ else if (!strcmp((const char *) node->name,
+ (const char *) "normalize")){
+ step = icu_chain_insert_step(chain, ICU_chain_step_type_normalize,
+ (const uint8_t *) xml_rule, status);
+ }
+ else if (!strcmp((const char *) node->name,
+ (const char *) "tokenize")){
+ step = icu_chain_insert_step(chain, ICU_chain_step_type_tokenize,
+ (const uint8_t *) xml_rule, status);
+ }
+ else if (!strcmp((const char *) node->name,
+ (const char *) "display")){
+ step = icu_chain_insert_step(chain, ICU_chain_step_type_display,
+ (const uint8_t *) "", status);
+ }
+ else if (!strcmp((const char *) node->name,
+ (const char *) "index")){
+ step = icu_chain_insert_step(chain, ICU_chain_step_type_index,
+ (const uint8_t *) "", status);
+ }
+ else if (!strcmp((const char *) node->name,
+ (const char *) "sortkey")){
+ step = icu_chain_insert_step(chain, ICU_chain_step_type_sortkey,
+ (const uint8_t *) "", status);
+ }
+
+ xmlFree(xml_rule);
+ if (!step || U_FAILURE(*status)){
+ icu_chain_destroy(chain);
+ return 0;
+ }
+
+
+ }
+
+ return chain;