mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-11 00:30:49 +00:00
Fix error unlinking old namespace
This commit is contained in:
parent
0d010003f9
commit
d5da27bcbc
1 changed files with 46 additions and 27 deletions
|
@ -39,8 +39,8 @@ cleanup_namespaces(xmlNodePtr node, xmlNsPtr ns)
|
||||||
if ((node == NULL) || (ns == NULL))
|
if ((node == NULL) || (ns == NULL))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((node->type == XML_ATTRIBUTE_NODE) ||
|
if ((node->type == XML_ATTRIBUTE_NODE)
|
||||||
(node->type == XML_ELEMENT_NODE))
|
|| (node->type == XML_ELEMENT_NODE))
|
||||||
{
|
{
|
||||||
xmlNsPtr ns1 = node->ns;
|
xmlNsPtr ns1 = node->ns;
|
||||||
|
|
||||||
|
@ -50,19 +50,23 @@ cleanup_namespaces(xmlNodePtr node, xmlNsPtr ns)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Either both the same or one NULL and the other the same
|
// Either both the same or one NULL and the other the same
|
||||||
if (ns1 != NULL &&
|
if (ns1 != NULL)
|
||||||
(((ns1->href == NULL) &&
|
{
|
||||||
(xmlStrcmp(ns1->prefix, ns->prefix) == 0)) ||
|
BOOL equalPrefix;
|
||||||
/*
|
|
||||||
((ns1->prefix == NULL) &&
|
equalPrefix = (xmlStrcmp(ns1->prefix, ns->prefix) == 0) ? YES : NO;
|
||||||
(xmlStrcmp(ns1->href, ns->href) == 0)) ||
|
|
||||||
*/
|
if (equalPrefix
|
||||||
((xmlStrcmp(ns1->prefix, ns->prefix) == 0) &&
|
&& ((ns1->href == NULL)
|
||||||
(xmlStrcmp(ns1->href, ns->href) == 0))))
|
|| (xmlStrcmp(ns1->href, ns->href) == 0)))
|
||||||
{
|
{
|
||||||
//xmlFreeNs(ns1);
|
xmlSetNs(node, ns);
|
||||||
xmlSetNs(node, ns);
|
if (ns1->href != NULL)
|
||||||
}
|
{
|
||||||
|
//xmlFreeNs(ns1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
cleanup_namespaces(node->children, ns);
|
cleanup_namespaces(node->children, ns);
|
||||||
cleanup_namespaces(node->next, ns);
|
cleanup_namespaces(node->next, ns);
|
||||||
|
@ -73,9 +77,11 @@ cleanup_namespaces(xmlNodePtr node, xmlNsPtr ns)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
BOOL
|
||||||
ensure_oldNs(xmlNodePtr node)
|
ensure_oldNs(xmlNodePtr node)
|
||||||
{
|
{
|
||||||
|
BOOL newDoc = NO;
|
||||||
|
|
||||||
if (node->doc == NULL)
|
if (node->doc == NULL)
|
||||||
{
|
{
|
||||||
// Create a private document for this node
|
// Create a private document for this node
|
||||||
|
@ -86,6 +92,7 @@ ensure_oldNs(xmlNodePtr node)
|
||||||
#else
|
#else
|
||||||
xmlSetTreeDoc(node, tmp);
|
xmlSetTreeDoc(node, tmp);
|
||||||
#endif
|
#endif
|
||||||
|
newDoc = YES;
|
||||||
}
|
}
|
||||||
if (node->doc->oldNs == NULL)
|
if (node->doc->oldNs == NULL)
|
||||||
{
|
{
|
||||||
|
@ -96,6 +103,7 @@ ensure_oldNs(xmlNodePtr node)
|
||||||
ns->prefix = xmlStrdup((const xmlChar *)"xml");
|
ns->prefix = xmlStrdup((const xmlChar *)"xml");
|
||||||
node->doc->oldNs = ns;
|
node->doc->oldNs = ns;
|
||||||
}
|
}
|
||||||
|
return newDoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -551,11 +559,15 @@ isEqualTree(xmlNodePtr nodeA, xmlNodePtr nodeB)
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
// Try to resolve half defined namespaces
|
// Try to resolve half defined namespaces
|
||||||
xmlNsPtr ns = tmp->oldNs;
|
xmlNsPtr ns;
|
||||||
xmlNsPtr last = NULL;
|
xmlNsPtr last = NULL;
|
||||||
|
|
||||||
ensure_oldNs(parentNode);
|
if (ensure_oldNs(parentNode))
|
||||||
|
{
|
||||||
|
detached = parentNode->doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
ns = tmp->oldNs;
|
||||||
while (ns != NULL)
|
while (ns != NULL)
|
||||||
{
|
{
|
||||||
BOOL resolved = NO;
|
BOOL resolved = NO;
|
||||||
|
@ -594,7 +606,7 @@ isEqualTree(xmlNodePtr nodeA, xmlNodePtr nodeB)
|
||||||
// Unlink in old
|
// Unlink in old
|
||||||
if (last == NULL)
|
if (last == NULL)
|
||||||
{
|
{
|
||||||
tmp->oldNs = NULL;
|
tmp->oldNs = tmp->oldNs->next;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1801,9 +1813,9 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const xmlChar *xmlName = XMLSTRING(name);
|
const xmlChar *xmlName = XMLSTRING(name);
|
||||||
xmlChar *prefix = NULL;
|
xmlChar *prefix = NULL;
|
||||||
xmlChar *localName;
|
xmlChar *localName;
|
||||||
|
|
||||||
if (NULL == xmlName)
|
if (NULL == xmlName)
|
||||||
{
|
{
|
||||||
|
@ -1814,8 +1826,8 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
|
||||||
localName = xmlSplitQName2(xmlName, &prefix);
|
localName = xmlSplitQName2(xmlName, &prefix);
|
||||||
if (prefix != NULL)
|
if (prefix != NULL)
|
||||||
{
|
{
|
||||||
if ((theNode->type == XML_ATTRIBUTE_NODE) ||
|
if ((theNode->type == XML_ATTRIBUTE_NODE)
|
||||||
(theNode->type == XML_ELEMENT_NODE))
|
|| (theNode->type == XML_ELEMENT_NODE))
|
||||||
{
|
{
|
||||||
if ((theNode->ns != NULL && theNode->ns->prefix == NULL))
|
if ((theNode->ns != NULL && theNode->ns->prefix == NULL))
|
||||||
{
|
{
|
||||||
|
@ -1835,7 +1847,10 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
|
||||||
{
|
{
|
||||||
xmlNsPtr oldNs;
|
xmlNsPtr oldNs;
|
||||||
|
|
||||||
ensure_oldNs(theNode);
|
if (ensure_oldNs(theNode))
|
||||||
|
{
|
||||||
|
detached = theNode->doc;
|
||||||
|
}
|
||||||
|
|
||||||
// Fake the name space and fix it later
|
// Fake the name space and fix it later
|
||||||
// This function is private, so re reimplemt it.
|
// This function is private, so re reimplemt it.
|
||||||
|
@ -1843,7 +1858,8 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
|
||||||
oldNs = theNode->doc->oldNs;
|
oldNs = theNode->doc->oldNs;
|
||||||
while (oldNs)
|
while (oldNs)
|
||||||
{
|
{
|
||||||
if (oldNs->prefix != NULL && xmlStrEqual(oldNs->prefix, prefix))
|
if (oldNs->prefix != NULL
|
||||||
|
&& xmlStrEqual(oldNs->prefix, prefix))
|
||||||
{
|
{
|
||||||
ns = oldNs;
|
ns = oldNs;
|
||||||
break;
|
break;
|
||||||
|
@ -1964,7 +1980,10 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
|
||||||
{
|
{
|
||||||
xmlNsPtr oldNs;
|
xmlNsPtr oldNs;
|
||||||
|
|
||||||
ensure_oldNs(theNode);
|
if (ensure_oldNs(theNode))
|
||||||
|
{
|
||||||
|
detached = theNode->doc;
|
||||||
|
}
|
||||||
|
|
||||||
// Fake the name space and fix it later
|
// Fake the name space and fix it later
|
||||||
// This function is private, so re reimplemt it.
|
// This function is private, so re reimplemt it.
|
||||||
|
|
Loading…
Reference in a new issue