mirror of
https://github.com/GNOME/libxml2.git
synced 2025-03-31 19:10:28 +08:00
some changes related to the new way of handling Result Value Tree, before
* tree.c xpath.c: some changes related to the new way of handling Result Value Tree, before 2.5.5 Daniel
This commit is contained in:
parent
d8da01cf37
commit
9adc0469d4
@ -1,3 +1,8 @@
|
||||
Mon Mar 24 19:38:05 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* tree.c xpath.c: some changes related to the new way of
|
||||
handling Result Value Tree, before 2.5.5
|
||||
|
||||
Mon Mar 24 16:36:23 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* configure.in NEWS: preparing release 2.5.5
|
||||
|
36
tree.c
36
tree.c
@ -2967,6 +2967,14 @@ xmlFreeNodeList(xmlNodePtr cur) {
|
||||
xmlFreeNsList((xmlNsPtr) cur);
|
||||
return;
|
||||
}
|
||||
if ((cur->type == XML_DOCUMENT_NODE) ||
|
||||
#ifdef LIBXML_DOCB_ENABLED
|
||||
(cur->type == XML_DOCB_DOCUMENT_NODE) ||
|
||||
(cur->type == XML_HTML_DOCUMENT_NODE)) {
|
||||
#endif
|
||||
xmlFreeDoc((xmlDocPtr) cur);
|
||||
return;
|
||||
}
|
||||
while (cur != NULL) {
|
||||
next = cur->next;
|
||||
/* unroll to speed up freeing the document */
|
||||
@ -4592,17 +4600,39 @@ xmlNodeGetContent(xmlNodePtr cur)
|
||||
return (ret);
|
||||
}
|
||||
case XML_ENTITY_NODE:
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
case XML_DOCUMENT_TYPE_NODE:
|
||||
case XML_NOTATION_NODE:
|
||||
case XML_DTD_NODE:
|
||||
case XML_XINCLUDE_START:
|
||||
case XML_XINCLUDE_END:
|
||||
return (NULL);
|
||||
case XML_DOCUMENT_NODE:
|
||||
#ifdef LIBXML_DOCB_ENABLED
|
||||
case XML_DOCB_DOCUMENT_NODE:
|
||||
#endif
|
||||
return (NULL);
|
||||
case XML_HTML_DOCUMENT_NODE: {
|
||||
xmlChar *tmp;
|
||||
xmlChar *res = NULL;
|
||||
|
||||
cur = cur->children;
|
||||
while (cur!= NULL) {
|
||||
if ((cur->type == XML_ELEMENT_NODE) ||
|
||||
(cur->type == XML_TEXT_NODE) ||
|
||||
(cur->type == XML_CDATA_SECTION_NODE)) {
|
||||
tmp = xmlNodeGetContent(cur);
|
||||
if (tmp != NULL) {
|
||||
if (res == NULL)
|
||||
res = tmp;
|
||||
else {
|
||||
res = xmlStrcat(res, tmp);
|
||||
xmlFree(tmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
cur = cur->next;
|
||||
}
|
||||
return(res);
|
||||
}
|
||||
case XML_NAMESPACE_DECL: {
|
||||
xmlChar *tmp;
|
||||
|
||||
|
31
xpath.c
31
xpath.c
@ -3134,21 +3134,24 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
|
||||
case XPATH_XSLT_TREE:
|
||||
if ((val->nodesetval != NULL) &&
|
||||
(val->nodesetval->nodeTab != NULL)) {
|
||||
xmlNodePtr cur, top, tmp;
|
||||
xmlNodePtr cur, tmp;
|
||||
xmlDocPtr top;
|
||||
|
||||
ret->boolval = 1;
|
||||
top = xmlCopyNode(val->nodesetval->nodeTab[0], 0);
|
||||
top = xmlNewDoc(NULL);
|
||||
top->name = (char *)
|
||||
xmlStrdup(val->nodesetval->nodeTab[0]->name);
|
||||
ret->user = top;
|
||||
if (top != NULL) {
|
||||
top->doc = (xmlDocPtr) top;
|
||||
top->doc = top;
|
||||
cur = val->nodesetval->nodeTab[0]->children;
|
||||
while (cur != NULL) {
|
||||
tmp = xmlDocCopyNode(cur, (xmlDocPtr) top, 1);
|
||||
xmlAddChild(top, tmp);
|
||||
tmp = xmlDocCopyNode(cur, top, 1);
|
||||
xmlAddChild((xmlNodePtr) top, tmp);
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
ret->nodesetval = xmlXPathNodeSetCreate(top);
|
||||
ret->nodesetval = xmlXPathNodeSetCreate((xmlNodePtr) top);
|
||||
} else
|
||||
ret->nodesetval = xmlXPathNodeSetCreate(NULL);
|
||||
/* Deallocate the copied tree value */
|
||||
@ -3279,8 +3282,6 @@ xmlXPathCastNumberToString (double val) {
|
||||
*/
|
||||
xmlChar *
|
||||
xmlXPathCastNodeToString (xmlNodePtr node) {
|
||||
if ((node != NULL) && (node->type == XML_DOCUMENT_NODE))
|
||||
node = xmlDocGetRootElement((xmlDocPtr) node);
|
||||
return(xmlNodeGetContent(node));
|
||||
}
|
||||
|
||||
@ -3859,6 +3860,16 @@ xmlXPathNodeValHash(xmlNodePtr node) {
|
||||
if (node == NULL)
|
||||
return(0);
|
||||
|
||||
if (node->type == XML_DOCUMENT_NODE) {
|
||||
tmp = xmlDocGetRootElement((xmlDocPtr) node);
|
||||
if (tmp == NULL)
|
||||
node = node->children;
|
||||
else
|
||||
node = tmp;
|
||||
|
||||
if (node == NULL)
|
||||
return(0);
|
||||
}
|
||||
|
||||
switch (node->type) {
|
||||
case XML_COMMENT_NODE:
|
||||
@ -4270,6 +4281,10 @@ xmlXPathEqualNodeSetString(xmlXPathObjectPtr arg, const xmlChar * str, int neq)
|
||||
if (neq)
|
||||
continue;
|
||||
return (1);
|
||||
} else if ((str2 == NULL) && (xmlStrEqual(str, BAD_CAST ""))) {
|
||||
if (neq)
|
||||
continue;
|
||||
return (1);
|
||||
} else if (neq) {
|
||||
if (str2 != NULL)
|
||||
xmlFree(str2);
|
||||
|
Loading…
x
Reference in New Issue
Block a user