From: Daiki Ueno Date: Fri, 25 Sep 2015 08:08:55 +0000 (+0900) Subject: its: Register namespaces for locNotePointer X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0ae5a97d7174d5587c55e6b788c6f87b86d8ab1;p=thirdparty%2Fgettext.git its: Register namespaces for locNotePointer --- diff --git a/gettext-tools/src/its.c b/gettext-tools/src/its.c index 6982fc4ab..df344428a 100644 --- a/gettext-tools/src/its.c +++ b/gettext-tools/src/its.c @@ -280,7 +280,7 @@ its_rule_destructor (struct its_rule_ty *pop) { size_t i; for (i = 0; pop->namespaces[i] != NULL; i++) - xmlFreeNsList (pop->namespaces[i]); + xmlFreeNs (pop->namespaces[i]); free (pop->namespaces); } } @@ -310,9 +310,8 @@ its_rule_apply (struct its_rule_ty *rule, struct its_pool_ty *pool, xmlDoc *doc) size_t i; for (i = 0; rule->namespaces[i] != NULL; i++) { - xmlNs *ns; - for (ns = rule->namespaces[i]; ns; ns = ns->next) - xmlXPathRegisterNs (context, ns->prefix, ns->href); + xmlNs *ns = rule->namespaces[i]; + xmlXPathRegisterNs (context, ns->prefix, ns->href); } } @@ -1233,10 +1232,12 @@ its_rule_list_extract_nodes (its_rule_list_ty *rules, } static char * -_its_get_content (xmlNode *node, const char *pointer) +_its_get_content (struct its_rule_list_ty *rules, xmlNode *node, + const char *pointer) { xmlXPathContext *context; xmlXPathObject *object; + size_t i; char *result; context = xmlXPathNewContext (node->doc); @@ -1246,6 +1247,20 @@ _its_get_content (xmlNode *node, const char *pointer) return NULL; } + for (i = 0; i < rules->nitems; i++) + { + struct its_rule_ty *rule = rules->items[i]; + if (rule->namespaces) + { + size_t i; + for (i = 0; rule->namespaces[i] != NULL; i++) + { + xmlNs *ns = rule->namespaces[i]; + xmlXPathRegisterNs (context, ns->prefix, ns->href); + } + } + } + object = xmlXPathNodeEval (node, BAD_CAST pointer, context); if (!object) { @@ -1305,7 +1320,7 @@ its_rule_list_extract_text (its_rule_list_ty *rules, { value = its_value_list_get_value (values, "locNotePointer"); if (value) - comment = _its_get_content (node, value); + comment = _its_get_content (rules, node, value); } value = its_value_list_get_value (values, "space");