+
+/** \brief fixes NS for root node of record data (bug #740) */
+static void fixup_xmlns(xmlNodePtr ptr, ODR o)
+{
+ /* should go towards root and collect NS not defined in the record here! */
+ xmlNodePtr p = ptr;
+
+ while (p)
+ {
+ assert(p->type == XML_ELEMENT_NODE);
+
+ p = p->parent;
+ while (p && p->type != XML_ELEMENT_NODE)
+ p = p->prev;
+ if (p)
+ {
+ xmlNsPtr ns = p->ns;
+ for (; ns; ns = ns->next)
+ {
+ xmlNsPtr n;
+ for (n = ptr->nsDef; n; n = n->next)
+ if ((n->prefix == 0 && ns->prefix == 0)
+ || (n->prefix && ns->prefix
+ && !strcmp((const char *) n->prefix,
+ (const char *) ns->prefix)))
+ {
+ break;
+ }
+ if (!n)
+ {
+ xmlNsPtr new_ns = xmlCopyNamespace(ns);
+
+ new_ns->next = ptr->nsDef;
+ ptr->nsDef = new_ns;
+ }
+ }
+ }
+ }
+}
+