| OLD | NEW |
| 1 /* | 1 /* |
| 2 * tree.c : implementation of access function for an XML tree. | 2 * tree.c : implementation of access function for an XML tree. |
| 3 * | 3 * |
| 4 * References: | 4 * References: |
| 5 * XHTML 1.0 W3C REC: http://www.w3.org/TR/2002/REC-xhtml1-20020801/ | 5 * XHTML 1.0 W3C REC: http://www.w3.org/TR/2002/REC-xhtml1-20020801/ |
| 6 * | 6 * |
| 7 * See Copyright for the status of this software. | 7 * See Copyright for the status of this software. |
| 8 * | 8 * |
| 9 * daniel@veillard.com | 9 * daniel@veillard.com |
| 10 * | 10 * |
| (...skipping 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 if (xmlBufAdd(buf, q, cur - q)) | 1444 if (xmlBufAdd(buf, q, cur - q)) |
| 1445 goto out; | 1445 goto out; |
| 1446 } | 1446 } |
| 1447 | 1447 |
| 1448 if (!xmlBufIsEmpty(buf)) { | 1448 if (!xmlBufIsEmpty(buf)) { |
| 1449 node = xmlNewDocText(doc, NULL); | 1449 node = xmlNewDocText(doc, NULL); |
| 1450 if (node == NULL) goto out; | 1450 if (node == NULL) goto out; |
| 1451 node->content = xmlBufDetach(buf); | 1451 node->content = xmlBufDetach(buf); |
| 1452 | 1452 |
| 1453 if (last == NULL) { | 1453 if (last == NULL) { |
| 1454 » last = ret = node; | 1454 » ret = node; |
| 1455 } else { | 1455 } else { |
| 1456 » last = xmlAddNextSibling(last, node); | 1456 » xmlAddNextSibling(last, node); |
| 1457 } | 1457 } |
| 1458 } else if (ret == NULL) { | 1458 } else if (ret == NULL) { |
| 1459 ret = xmlNewDocText(doc, BAD_CAST ""); | 1459 ret = xmlNewDocText(doc, BAD_CAST ""); |
| 1460 } | 1460 } |
| 1461 | 1461 |
| 1462 out: | 1462 out: |
| 1463 xmlBufFree(buf); | 1463 xmlBufFree(buf); |
| 1464 return(ret); | 1464 return(ret); |
| 1465 } | 1465 } |
| 1466 | 1466 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 * Handle the last piece of text. | 1632 * Handle the last piece of text. |
| 1633 */ | 1633 */ |
| 1634 xmlBufAdd(buf, q, cur - q); | 1634 xmlBufAdd(buf, q, cur - q); |
| 1635 } | 1635 } |
| 1636 | 1636 |
| 1637 if (!xmlBufIsEmpty(buf)) { | 1637 if (!xmlBufIsEmpty(buf)) { |
| 1638 node = xmlNewDocText(doc, NULL); | 1638 node = xmlNewDocText(doc, NULL); |
| 1639 node->content = xmlBufDetach(buf); | 1639 node->content = xmlBufDetach(buf); |
| 1640 | 1640 |
| 1641 if (last == NULL) { | 1641 if (last == NULL) { |
| 1642 » last = ret = node; | 1642 » ret = node; |
| 1643 } else { | 1643 } else { |
| 1644 » last = xmlAddNextSibling(last, node); | 1644 » xmlAddNextSibling(last, node); |
| 1645 } | 1645 } |
| 1646 } | 1646 } |
| 1647 | 1647 |
| 1648 out: | 1648 out: |
| 1649 xmlBufFree(buf); | 1649 xmlBufFree(buf); |
| 1650 return(ret); | 1650 return(ret); |
| 1651 } | 1651 } |
| 1652 | 1652 |
| 1653 /** | 1653 /** |
| 1654 * xmlNodeListGetString: | 1654 * xmlNodeListGetString: |
| (...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2792 void | 2792 void |
| 2793 xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) { | 2793 xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) { |
| 2794 xmlAttrPtr prop; | 2794 xmlAttrPtr prop; |
| 2795 | 2795 |
| 2796 if ((tree == NULL) || (tree->type == XML_NAMESPACE_DECL)) | 2796 if ((tree == NULL) || (tree->type == XML_NAMESPACE_DECL)) |
| 2797 return; | 2797 return; |
| 2798 if (tree->doc != doc) { | 2798 if (tree->doc != doc) { |
| 2799 if(tree->type == XML_ELEMENT_NODE) { | 2799 if(tree->type == XML_ELEMENT_NODE) { |
| 2800 prop = tree->properties; | 2800 prop = tree->properties; |
| 2801 while (prop != NULL) { | 2801 while (prop != NULL) { |
| 2802 if (prop->atype == XML_ATTRIBUTE_ID) { |
| 2803 xmlRemoveID(tree->doc, prop); |
| 2804 } |
| 2805 |
| 2802 prop->doc = doc; | 2806 prop->doc = doc; |
| 2803 xmlSetListDoc(prop->children, doc); | 2807 xmlSetListDoc(prop->children, doc); |
| 2808 |
| 2809 /* |
| 2810 * TODO: ID attributes should be also added to the new |
| 2811 * document, but this breaks things like xmlReplaceNode. |
| 2812 * The underlying problem is that xmlRemoveID is only called |
| 2813 * if a node is destroyed, not if it's unlinked. |
| 2814 */ |
| 2815 #if 0 |
| 2816 if (xmlIsID(doc, tree, prop)) { |
| 2817 xmlChar *idVal = xmlNodeListGetString(doc, prop->children, |
| 2818 1); |
| 2819 xmlAddID(NULL, doc, idVal, prop); |
| 2820 } |
| 2821 #endif |
| 2822 |
| 2804 prop = prop->next; | 2823 prop = prop->next; |
| 2805 } | 2824 } |
| 2806 } | 2825 } |
| 2807 if (tree->children != NULL) | 2826 if (tree->children != NULL) |
| 2808 xmlSetListDoc(tree->children, doc); | 2827 xmlSetListDoc(tree->children, doc); |
| 2809 tree->doc = doc; | 2828 tree->doc = doc; |
| 2810 } | 2829 } |
| 2811 } | 2830 } |
| 2812 | 2831 |
| 2813 /** | 2832 /** |
| (...skipping 7279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10093 } | 10112 } |
| 10094 default: | 10113 default: |
| 10095 break; | 10114 break; |
| 10096 } | 10115 } |
| 10097 } | 10116 } |
| 10098 return (0); | 10117 return (0); |
| 10099 } | 10118 } |
| 10100 | 10119 |
| 10101 #define bottom_tree | 10120 #define bottom_tree |
| 10102 #include "elfgcchack.h" | 10121 #include "elfgcchack.h" |
| OLD | NEW |