Lines Matching refs:cur
364 const xmlChar *cur = value;
374 while (IS_BLANK_CH(*cur)) cur++;
375 if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) ||
376 (*cur == '_'))
377 cur++;
380 while (((*cur >= 'a') && (*cur <= 'z')) ||
381 ((*cur >= 'A') && (*cur <= 'Z')) ||
382 ((*cur >= '0') && (*cur <= '9')) ||
383 (*cur == '_') || (*cur == '-') || (*cur == '.'))
384 cur++;
386 while (IS_BLANK_CH(*cur)) cur++;
387 if (*cur == 0)
394 cur = value;
395 c = CUR_SCHAR(cur, l);
398 cur += l;
399 c = CUR_SCHAR(cur, l);
404 cur += l;
405 c = CUR_SCHAR(cur, l);
409 cur += l;
410 c = CUR_SCHAR(cur, l);
414 cur += l;
415 c = CUR_SCHAR(cur, l);
438 const xmlChar *cur = value;
447 while (IS_BLANK_CH(*cur)) cur++;
448 if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) ||
449 (*cur == '_'))
450 cur++;
453 while (((*cur >= 'a') && (*cur <= 'z')) ||
454 ((*cur >= 'A') && (*cur <= 'Z')) ||
455 ((*cur >= '0') && (*cur <= '9')) ||
456 (*cur == '_') || (*cur == '-') || (*cur == '.'))
457 cur++;
458 if (*cur == ':') {
459 cur++;
460 if (((*cur >= 'a') && (*cur <= 'z')) ||
461 ((*cur >= 'A') && (*cur <= 'Z')) ||
462 (*cur == '_'))
463 cur++;
466 while (((*cur >= 'a') && (*cur <= 'z')) ||
467 ((*cur >= 'A') && (*cur <= 'Z')) ||
468 ((*cur >= '0') && (*cur <= '9')) ||
469 (*cur == '_') || (*cur == '-') || (*cur == '.'))
470 cur++;
473 while (IS_BLANK_CH(*cur)) cur++;
474 if (*cur == 0)
481 cur = value;
482 c = CUR_SCHAR(cur, l);
485 cur += l;
486 c = CUR_SCHAR(cur, l);
491 cur += l;
492 c = CUR_SCHAR(cur, l);
496 cur += l;
497 c = CUR_SCHAR(cur, l);
500 cur += l;
501 c = CUR_SCHAR(cur, l);
504 cur += l;
505 c = CUR_SCHAR(cur, l);
509 cur += l;
510 c = CUR_SCHAR(cur, l);
515 cur += l;
516 c = CUR_SCHAR(cur, l);
536 const xmlChar *cur = value;
545 while (IS_BLANK_CH(*cur)) cur++;
546 if (((*cur >= 'a') && (*cur <= 'z')) || ((*cur >= 'A') && (*cur <= 'Z')) ||
547 (*cur == '_') || (*cur == ':'))
548 cur++;
551 while (((*cur >= 'a') && (*cur <= 'z')) ||
552 ((*cur >= 'A') && (*cur <= 'Z')) ||
553 ((*cur >= '0') && (*cur <= '9')) ||
554 (*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':'))
555 cur++;
557 while (IS_BLANK_CH(*cur)) cur++;
558 if (*cur == 0)
565 cur = value;
566 c = CUR_SCHAR(cur, l);
569 cur += l;
570 c = CUR_SCHAR(cur, l);
575 cur += l;
576 c = CUR_SCHAR(cur, l);
579 cur += l;
580 c = CUR_SCHAR(cur, l);
584 cur += l;
585 c = CUR_SCHAR(cur, l);
605 const xmlChar *cur = value;
614 while (IS_BLANK_CH(*cur)) cur++;
615 if (((*cur >= 'a') && (*cur <= 'z')) ||
616 ((*cur >= 'A') && (*cur <= 'Z')) ||
617 ((*cur >= '0') && (*cur <= '9')) ||
618 (*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':'))
619 cur++;
622 while (((*cur >= 'a') && (*cur <= 'z')) ||
623 ((*cur >= 'A') && (*cur <= 'Z')) ||
624 ((*cur >= '0') && (*cur <= '9')) ||
625 (*cur == '_') || (*cur == '-') || (*cur == '.') || (*cur == ':'))
626 cur++;
628 while (IS_BLANK_CH(*cur)) cur++;
629 if (*cur == 0)
636 cur = value;
637 c = CUR_SCHAR(cur, l);
640 cur += l;
641 c = CUR_SCHAR(cur, l);
647 cur += l;
648 c = CUR_SCHAR(cur
651 cur += l;
652 c = CUR_SCHAR(cur, l);
656 cur += l;
657 c = CUR_SCHAR(cur, l);
718 xmlNsPtr cur;
729 cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
730 if (cur == NULL) {
734 memset(cur, 0, sizeof(xmlNs));
735 cur->type = XML_LOCAL_NAMESPACE;
738 cur->href = xmlStrdup(href);
740 cur->prefix = xmlStrdup(prefix);
748 node->nsDef = cur;
752 if (((prev->prefix == NULL) && (cur->prefix == NULL)) ||
753 (xmlStrEqual(prev->prefix, cur->prefix))) {
754 xmlFreeNs(cur);
759 if (((prev->prefix == NULL) && (cur->prefix == NULL)) ||
760 (xmlStrEqual(prev->prefix, cur->prefix))) {
761 xmlFreeNs(cur);
765 prev->next = cur;
768 return(cur);
792 * @cur: the namespace pointer
797 xmlFreeNs(xmlNsPtr cur) {
798 if (cur == NULL) {
805 if (cur->href != NULL) xmlFree((char *) cur->href);
806 if (cur->prefix != NULL) xmlFree((char *) cur->prefix);
807 xmlFree(cur);
812 * @cur: the first namespace pointer
817 xmlFreeNsList(xmlNsPtr cur) {
819 if (cur == NULL) {
826 while (cur != NULL) {
827 next = cur->next;
828 xmlFreeNs(cur);
829 cur = next;
848 xmlDtdPtr cur;
863 cur = (xmlDtdPtr) xmlMalloc(sizeof(xmlDtd));
864 if (cur == NULL) {
868 memset(cur, 0 , sizeof(xmlDtd));
869 cur->type = XML_DTD_NODE;
872 cur->name = xmlStrdup(name);
874 cur->ExternalID = xmlStrdup(ExternalID);
876 cur->SystemID = xmlStrdup(SystemID);
878 doc->extSubset = cur;
879 cur->doc = doc;
882 xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
883 return(cur);
896 xmlNodePtr cur;
900 cur = doc->children;
901 while (cur != NULL) {
902 if (cur->type == XML_DTD_NODE)
903 return((xmlDtdPtr) cur);
904 cur = cur->next;
922 xmlDtdPtr cur;
937 cur = (xmlDtdPtr) xmlMalloc(sizeof(xmlDtd));
938 if (cur == NULL) {
942 memset(cur, 0, sizeof(xmlDtd));
943 cur->type = XML_DTD_NODE;
946 cur->name = xmlStrdup(name);
947 if (cur->name == NULL) {
949 xmlFree(cur);
954 cur->ExternalID = xmlStrdup(ExternalID);
955 if (cur->ExternalID == NULL) {
957 if (cur->name != NULL)
958 xmlFree((char *)cur->name);
959 xmlFree(cur);
964 cur->SystemID = xmlStrdup(SystemID);
965 if (cur->SystemID == NULL) {
967 if (cur->name != NULL)
968 xmlFree((char *)cur->name);
969 if (cur->ExternalID != NULL)
970 xmlFree((char *)cur->ExternalID);
971 xmlFree(cur);
976 doc->intSubset = cur;
977 cur->parent = doc;
978 cur->doc = doc;
980 doc->children = (xmlNodePtr) cur;
981 doc->last = (xmlNodePtr) cur;
987 prev->prev = (xmlNodePtr) cur;
988 cur->next = prev;
989 doc->children = (xmlNodePtr) cur;
997 cur->prev = doc->last;
998 cur->prev->next = (xmlNodePtr) cur;
999 cur->next = NULL;
1000 doc->last = (xmlNodePtr) cur;
1002 cur->next = next;
1003 cur->prev = next->prev;
1004 if (cur->prev == NULL)
1005 doc->children = (xmlNodePtr) cur;
1007 cur->prev->next = (xmlNodePtr) cur;
1008 next->prev = (xmlNodePtr) cur;
1015 xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
1016 return(cur);
1069 * @cur: the DTD structure to free up
1074 xmlFreeDtd(xmlDtdPtr cur) {
1077 if (cur == NULL) {
1080 if (cur->doc != NULL) dict = cur->doc->dict;
1083 xmlDeregisterNodeDefaultValue((xmlNodePtr)cur);
1085 if (cur->children != NULL) {
1086 xmlNodePtr next, c = cur->children;
1104 DICT_FREE(cur->name)
1105 DICT_FREE(cur->SystemID)
1106 DICT_FREE(cur->ExternalID)
1108 if (cur->notations != NULL)
1109 xmlFreeNotationTable((xmlNotationTablePtr) cur->notations);
1111 if (cur->elements != NULL)
1112 xmlFreeElementTable((xmlElementTablePtr) cur->elements);
1113 if (cur->attributes != NULL)
1114 xmlFreeAttributeTable((xmlAttributeTablePtr) cur->attributes);
1115 if (cur->entities != NULL)
1116 xmlFreeEntitiesTable((xmlEntitiesTablePtr) cur->entities);
1117 if (cur->pentities != NULL)
1118 xmlFreeEntitiesTable((xmlEntitiesTablePtr) cur->pentities);
1120 xmlFree(cur);
1133 xmlDocPtr cur;
1141 cur = (xmlDocPtr) xmlMalloc(sizeof(xmlDoc));
1142 if (cur == NULL) {
1146 memset(cur, 0, sizeof(xmlDoc));
1147 cur->type = XML_DOCUMENT_NODE;
1149 cur->version = xmlStrdup(version);
1150 if (cur->version == NULL) {
1152 xmlFree(cur);
1155 cur->standalone = -1;
1156 cur->compression = -1; /* not initialized */
1157 cur->doc = cur;
1158 cur->parseFlags = 0;
1159 cur->properties = XML_DOC_USERBUILT;
1165 cur->charset = XML_CHAR_ENCODING_UTF8;
1168 xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
1169 return(cur);
1174 * @cur: pointer to the document
1179 xmlFreeDoc(xmlDocPtr cur) {
1183 if (cur == NULL) {
1192 xmlDebugCheckDocument(stderr, cur);
1196 if (cur != NULL) dict = cur->dict;
1199 xmlDeregisterNodeDefaultValue((xmlNodePtr)cur);
1204 if (cur->ids != NULL) xmlFreeIDTable((xmlIDTablePtr) cur->ids);
1205 cur->ids = NULL;
1206 if (cur->refs != NULL) xmlFreeRefTable((xmlRefTablePtr) cur->refs);
1207 cur->refs = NULL;
1208 extSubset = cur->extSubset;
1209 intSubset = cur->intSubset;
1213 xmlUnlinkNode((xmlNodePtr) cur->extSubset);
1214 cur->extSubset = NULL;
1218 xmlUnlinkNode((xmlNodePtr) cur->intSubset);
1219 cur->intSubset = NULL;
1223 if (cur->children != NULL) xmlFreeNodeList(cur->children);
1224 if (cur->oldNs != NULL) xmlFreeNsList(cur->oldNs);
1226 DICT_FREE(cur->version)
1227 DICT_FREE(cur->name)
1228 DICT_FREE(cur->encoding)
1229 DICT_FREE(cur->URL)
1230 xmlFree(cur);
1249 const xmlChar *cur = value, *end = cur + len;
1255 q = cur;
1256 while ((cur < end) && (*cur != 0)) {
1257 if (cur[0] == '&') {
1264 if (cur != q) {
1266 xmlNodeAddContentLen(last, q, cur - q);
1268 node = xmlNewDocTextLen(doc, q, cur - q);
1279 q = cur;
1280 if ((cur + 2 < end) && (cur[1] == '#') && (cur[2] == 'x')) {
1281 cur += 3;
1282 if (cur < end)
1283 tmp = *cur;
1299 cur++;
1300 if (cur < end)
1301 tmp = *cur;
1306 cur++;
1307 q = cur;
1308 } else if ((cur + 1 < end) && (cur[1] == '#')) {
1309 cur += 2;
1310 if (cur < end)
1311 tmp = *cur;
1323 cur++;
1324 if (cur < end)
1325 tmp = *cur;
1330 cur++;
1331 q = cur;
1336 cur++;
1337 q = cur;
1338 while ((cur < end) && (*cur != 0) && (*cur != ';')) cur++;
1339 if ((cur >= end) || (*cur == 0)) {
1344 if (cur != q) {
1348 val = xmlStrndup(q, cur - q);
1391 cur++;
1392 q = cur;
1411 cur++;
1413 if ((cur != q) || (ret == NULL)) {
1418 xmlNodeAddContentLen(last, q, cur - q);
1420 node = xmlNewDocTextLen(doc, q, cur - q);
1446 const xmlChar *cur = value;
1452 q = cur;
1453 while (*cur != 0) {
1454 if (cur[0] == '&') {
1461 if (cur != q) {
1463 xmlNodeAddContentLen(last, q, cur - q);
1465 node = xmlNewDocTextLen(doc, q, cur - q);
1476 q = cur;
1477 if ((cur[1] == '#') && (cur[2] == 'x')) {
1478 cur += 3;
1479 tmp = *cur;
1493 cur++;
1494 tmp = *cur;
1497 cur++;
1498 q = cur;
1499 } else if (cur[1] == '#') {
1500 cur += 2;
1501 tmp = *cur;
1511 cur++;
1512 tmp = *cur;
1515 cur++;
1516 q = cur;
1521 cur++;
1522 q = cur;
1523 while ((*cur != 0) && (*cur != ';')) cur++;
1524 if (*cur == 0) {
1529 if (cur != q) {
1533 val = xmlStrndup(q, cur - q);
1575 cur++;
1576 q = cur;
1596 cur++;
1598 if ((cur != q) || (ret == NULL)) {
1603 xmlNodeAddContentLen(last, q, cur - q);
1605 node = xmlNewDocTextLen(doc, q, cur - q);
1786 xmlAttrPtr cur;
1800 cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
1801 if (cur == NULL) {
1809 memset(cur, 0, sizeof(xmlAttr));
1810 cur->type = XML_ATTRIBUTE_NODE;
1812 cur->parent = node;
1815 cur->doc = doc;
1817 cur->ns = ns;
1821 cur->name = (xmlChar *) xmlDictLookup(doc->dict, name, -1);
1823 cur->name = xmlStrdup(name);
1825 cur->name = name;
1836 cur->children = xmlNewDocText(doc, value);
1837 cur->last = NULL;
1838 tmp = cur->children;
1840 tmp->parent = (xmlNodePtr) cur;
1842 cur->last = tmp;
1852 node->properties = cur;
1858 prev->next = cur;
1859 cur->prev = prev;
1863 if (xmlIsID((node == NULL) ? NULL : node->doc, node, cur) == 1)
1864 xmlAddID(NULL, node->doc, value, cur);
1867 xmlRegisterNodeDefaultValue((xmlNodePtr) cur);
1868 return (cur);
1958 xmlAttrPtr cur;
1971 cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
1972 if (cur == NULL) {
1976 memset(cur, 0, sizeof(xmlAttr));
1977 cur->type = XML_ATTRIBUTE_NODE;
1980 cur->name = xmlDictLookup(doc->dict, name, -1);
1982 cur->name = xmlStrdup(name);
1983 cur->doc = doc;
1987 cur->children = xmlStringGetNodeList(doc, value);
1988 cur->last = NULL;
1990 tmp = cur->children;
1992 tmp->parent = (xmlNodePtr) cur;
1994 cur->last = tmp;
2000 xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
2001 return(cur);
2006 * @cur: the first property in the list
2011 xmlFreePropList(xmlAttrPtr cur) {
2013 if (cur == NULL) return;
2014 while (cur != NULL) {
2015 next = cur->next;
2016 xmlFreeProp(cur);
2017 cur = next;
2023 * @cur: an attribute
2028 xmlFreeProp(xmlAttrPtr cur) {
2030 if (cur == NULL) return;
2032 if (cur->doc != NULL) dict = cur->doc->dict;
2035 xmlDeregisterNodeDefaultValue((xmlNodePtr)cur);
2038 if ((cur->doc != NULL) && (cur->atype == XML_ATTRIBUTE_ID)) {
2039 xmlRemoveID(cur->doc, cur);
2041 if (cur->children != NULL) xmlFreeNodeList(cur->children);
2042 DICT_FREE(cur->name)
2043 xmlFree(cur);
2048 * @cur: an attribute
2056 xmlRemoveProp(xmlAttrPtr cur) {
2058 if (cur == NULL) {
2061 "xmlRemoveProp : cur == NULL\n");
2065 if (cur->parent == NULL) {
2068 "xmlRemoveProp : cur->parent == NULL\n");
2072 tmp = cur->parent->properties;
2073 if (tmp == cur) {
2074 cur->parent->properties = cur->next;
2075 if (cur->next != NULL)
2076 cur->next->prev = NULL;
2077 xmlFreeProp(cur);
2081 if (tmp->next == cur) {
2082 tmp->next = cur->next;
2085 xmlFreeProp(cur);
2108 xmlNodePtr cur;
2121 cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
2122 if (cur == NULL) {
2126 memset(cur, 0, sizeof(xmlNode));
2127 cur->type = XML_PI_NODE;
2130 cur->name = xmlDictLookup(doc->dict, name, -1);
2132 cur->name = xmlStrdup(name);
2134 cur->content = xmlStrdup(content);
2136 cur->doc = doc;
2139 xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
2140 return(cur);
2170 xmlNodePtr cur;
2183 cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
2184 if (cur == NULL) {
2188 memset(cur, 0, sizeof(xmlNode));
2189 cur->type = XML_ELEMENT_NODE;
2191 cur->name = xmlStrdup(name);
2192 cur->ns = ns;
2195 xmlRegisterNodeDefaultValue(cur);
2196 return(cur);
2212 xmlNodePtr cur;
2225 cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
2226 if (cur == NULL) {
2231 memset(cur, 0, sizeof(xmlNode));
2232 cur->type = XML_ELEMENT_NODE;
2234 cur->name = name;
2235 cur->ns = ns;
2238 xmlRegisterNodeDefaultValue((xmlNodePtr)cur);
2239 return(cur);
2261 xmlNodePtr cur;
2264 cur = xmlNewNodeEatName(ns, (xmlChar *)
2267 cur = xmlNewNode(ns, name);
2268 if (cur != NULL) {
2269 cur->doc = doc;
2271 cur->children = xmlStringGetNodeList(doc, content);
2272 UPDATE_LAST_CHILD_AND_PARENT(cur)
2276 return(cur);
2298 xmlNodePtr cur;
2300 cur = xmlNewNodeEatName(ns, name);
2301 if (cur != NULL) {
2302 cur->doc = doc;
2304 cur->children = xmlStringGetNodeList(doc, content);
2305 UPDATE_LAST_CHILD_AND_PARENT(cur)
2313 return(cur);
2332 xmlNodePtr cur;
2334 cur = xmlNewDocNode(doc, ns, name, NULL);
2335 if (cur != NULL) {
2336 cur->doc = doc;
2338 cur->children = xmlNewDocText(doc, content);
2339 UPDATE_LAST_CHILD_AND_PARENT(cur)
2342 return(cur);
2354 xmlNodePtr cur;
2359 cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
2360 if (cur == NULL) {
2364 memset(cur, 0, sizeof(xmlNode));
2365 cur->type = XML_DOCUMENT_FRAG_NODE;
2367 cur->doc = doc;
2370 xmlRegisterNodeDefaultValue(cur);
2371 return(cur);
2384 xmlNodePtr cur;
2389 cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
2390 if (cur == NULL) {
2394 memset(cur, 0, sizeof(xmlNode));
2395 cur->type = XML_TEXT_NODE;
2397 cur->name = xmlStringText;
2399 cur->content = xmlStrdup(content);
2403 xmlRegisterNodeDefaultValue(cur);
2404 return(cur);
2430 xmlNodePtr cur, prev;
2453 cur = xmlNewDocRawNode(parent->doc, parent->ns, name, content);
2455 cur = xmlNewDocRawNode(parent->doc, ns, name, content);
2459 cur = xmlNewDocRawNode((xmlDocPtr) parent, NULL, name, content);
2461 cur = xmlNewDocRawNode((xmlDocPtr) parent, ns, name, content);
2463 cur = xmlNewDocRawNode( parent->doc, ns, name, content);
2467 if (cur == NULL) return(NULL);
2472 cur->type = XML_ELEMENT_NODE;
2473 cur->parent = parent;
2474 cur->doc = parent->doc;
2476 parent->children = cur;
2477 parent->last = cur;
2480 prev->next = cur;
2481 cur->prev = prev;
2482 parent->last = cur;
2485 return(cur);
2499 xmlNodePtr cur;
2507 cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
2508 if (cur == NULL) {
2512 memset(cur, 0, sizeof(xmlNode));
2513 cur->type = XML_ENTITY_REF_NODE;
2515 cur->doc = doc;
2521 cur->name = xmlStrndup(name, len - 1);
2523 cur->name = xmlStrndup(name, len);
2525 cur->name = xmlStrdup(name);
2528 xmlRegisterNodeDefaultValue(cur);
2529 return(cur);
2542 xmlNodePtr cur;
2551 cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
2552 if (cur == NULL) {
2556 memset(cur, 0, sizeof(xmlNode));
2557 cur->type = XML_ENTITY_REF_NODE;
2559 cur->doc = doc;
2565 cur->name = xmlStrndup(name, len - 1);
2567 cur->name = xmlStrndup(name, len);
2569 cur->name = xmlStrdup(name);
2571 ent = xmlGetDocEntity(doc, cur->name);
2573 cur->content = ent->content;
2579 cur->children = (xmlNodePtr) ent;
2580 cur->last = (xmlNodePtr) ent;
2584 xmlRegisterNodeDefaultValue(cur);
2585 return(cur);
2598 xmlNodePtr cur;
2600 cur = xmlNewText(content);
2601 if (cur != NULL) cur->doc = doc;
2602 return(cur);
2615 xmlNodePtr cur;
2620 cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
2621 if (cur == NULL) {
2625 memset(cur, 0, sizeof(xmlNode));
2626 cur->type = XML_TEXT_NODE;
2628 cur->name = xmlStringText;
2630 cur->content = xmlStrndup(content, len);
2634 xmlRegisterNodeDefaultValue(cur);
2635 return(cur);
2650 xmlNodePtr cur;
2652 cur = xmlNewTextLen(content, len);
2653 if (cur != NULL) cur->doc = doc;
2654 return(cur);
2666 xmlNodePtr cur;
2671 cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
2672 if (cur == NULL) {
2676 memset(cur, 0, sizeof(xmlNode));
2677 cur->type = XML_COMMENT_NODE;
2679 cur->name = xmlStringComment;
2681 cur->content = xmlStrdup(content);
2685 xmlRegisterNodeDefaultValue(cur);
2686 return(cur);
2700 xmlNodePtr cur;
2705 cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
2706 if (cur == NULL) {
2710 memset(cur, 0, sizeof(xmlNode));
2711 cur->type = XML_CDATA_SECTION_NODE;
2712 cur->doc = doc;
2715 cur->content = xmlStrndup(content, len);
2719 xmlRegisterNodeDefaultValue(cur);
2720 return(cur);
2733 xmlNodePtr cur;
2735 cur = xmlNewComment(content);
2736 if (cur != NULL) cur->doc = doc;
2737 return(cur);
2777 xmlNodePtr cur;
2781 cur = list;
2782 while (cur != NULL) {
2783 if (cur->doc != doc)
2784 xmlSetTreeDoc(cur, doc);
2785 cur = cur->next;
2810 xmlNodePtr cur, prev;
2833 cur = xmlNewDocNode(parent->doc, parent->ns, name, content);
2835 cur = xmlNewDocNode(parent->doc, ns, name, content);
2839 cur = xmlNewDocNode((xmlDocPtr) parent, NULL, name, content);
2841 cur = xmlNewDocNode((xmlDocPtr) parent, ns, name, content);
2843 cur = xmlNewDocNode( parent->doc, ns, name, content);
2847 if (cur == NULL) return(NULL);
2852 cur->type = XML_ELEMENT_NODE;
2853 cur->parent = parent;
2854 cur->doc = parent->doc;
2856 parent->children = cur;
2857 parent->last = cur;
2860 prev->next = cur;
2861 cur->prev = prev;
2862 parent->last = cur;
2865 return(cur);
2872 * @cur: the base attribute passed to calling function
2875 * Add a new attribute after @prev using @cur as base attribute.
2876 * When inserting before @cur, @prev is passed as @cur->prev.
2877 * When inserting after @cur, @prev is passed as @cur.
2883 xmlAddPropSibling(xmlNodePtr prev, xmlNodePtr cur, xmlNodePtr prop) {
2886 if (cur->type != XML_ATTRIBUTE_NODE)
2891 attr = xmlHasNsProp(cur->parent, prop->name, NULL);
2893 attr = xmlHasNsProp(cur->parent, prop->name, prop->ns->href);
2895 if (prop->doc != cur->doc) {
2896 xmlSetTreeDoc(prop, cur->doc);
2898 prop->parent = cur->parent;
2906 prop->next = cur;
2907 cur->prev = prop;
2920 * @cur: the child node
2923 * Add a new node @elem as the next sibling of @cur
2933 xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
2934 if (cur == NULL) {
2937 "xmlAddNextSibling : cur == NULL\n");
2949 if (cur == elem) {
2952 "xmlAddNextSibling : cur == elem\n");
2960 if (cur->type == XML_TEXT_NODE) {
2961 xmlNodeAddContent(cur, elem->content);
2963 return(cur);
2965 if ((cur->next != NULL) && (cur->next->type == XML_TEXT_NODE) &&
2966 (cur->name == cur->next->name)) {
2970 tmp = xmlStrcat(tmp, cur->next->content);
2971 xmlNodeSetContent(cur->next, tmp);
2974 return(cur->next);
2977 return xmlAddPropSibling(cur, cur, elem);
2980 if (elem->doc != cur->doc) {
2981 xmlSetTreeDoc(elem, cur->doc);
2983 elem->parent = cur->parent;
2984 elem->prev = cur;
2985 elem->next = cur->next;
2986 cur->next = elem;
2989 if ((elem->parent != NULL) && (elem->parent->last == cur))
2998 * @cur: the child node
3001 * Add a new node @elem as the previous sibling of @cur
3011 xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) {
3012 if (cur == NULL) {
3015 "xmlAddPrevSibling : cur == NULL\n");
3027 if (cur == elem) {
3030 "xmlAddPrevSibling : cur == elem\n");
3038 if (cur->type == XML_TEXT_NODE) {
3042 tmp = xmlStrcat(tmp, cur->content);
3043 xmlNodeSetContent(cur, tmp);
3046 return(cur);
3048 if ((cur->prev != NULL) && (cur->prev->type == XML_TEXT_NODE) &&
3049 (cur->name == cur->prev->name)) {
3050 xmlNodeAddContent(cur->prev, elem->content);
3052 return(cur->prev);
3055 return xmlAddPropSibling(cur->prev, cur, elem);
3058 if (elem->doc != cur->doc) {
3059 xmlSetTreeDoc(elem, cur->doc);
3061 elem->parent = cur->parent;
3062 elem->next = cur;
3063 elem->prev = cur->prev;
3064 cur->prev = elem;
3067 if ((elem->parent != NULL) && (elem->parent->children == cur)) {
3076 * @cur: the child node
3079 * Add a new element @elem to the list of siblings of @cur
3087 xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
3090 if (cur == NULL) {
3093 "xmlAddSibling : cur == NULL\n");
3110 if ((cur->type != XML_ATTRIBUTE_NODE) && (cur->parent != NULL) &&
3111 (cur->parent->children != NULL) &&
3112 (cur->parent->last != NULL) &&
3113 (cur->parent->last->next == NULL)) {
3114 cur = cur->parent->last;
3116 while (cur->next != NULL) cur = cur->next;
3121 if ((cur->type == XML_TEXT_NODE) && (elem->type == XML_TEXT_NODE) &&
3122 (cur->name == elem->name)) {
3123 xmlNodeAddContent(cur, elem->content);
3125 return(cur);
3127 return xmlAddPropSibling(cur, cur, elem);
3130 if (elem->doc != cur->doc) {
3131 xmlSetTreeDoc(elem, cur->doc);
3133 parent = cur->parent;
3134 elem->prev = cur;
3137 cur->next = elem;
3147 * @cur: the first node in the list
3150 * merging adjacent TEXT nodes (@cur may be freed)
3155 xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
3166 if (cur == NULL) {
3174 if ((cur->doc != NULL) && (parent->doc != NULL) &&
3175 (cur->doc != parent->doc)) {
3187 parent->children = cur;
3190 * If cur and parent->last both are TEXT nodes, then merge them.
3192 if ((cur->type == XML_TEXT_NODE) &&
3194 (cur->name == parent->last->name)) {
3195 xmlNodeAddContent(parent->last, cur->content);
3199 if (cur->next == NULL) {
3200 xmlFreeNode(cur);
3203 prev = cur;
3204 cur = cur->next;
3208 prev->next = cur;
3209 cur->prev = prev;
3211 while (cur->next != NULL) {
3212 cur->parent = parent;
3213 if (cur->doc != parent->doc) {
3214 xmlSetTreeDoc(cur, parent->doc);
3216 cur = cur->next;
3218 cur->parent = parent;
3220 if (cur->doc != parent->doc) {
3221 xmlSetTreeDoc(cur, parent->doc);
3223 parent->last = cur;
3225 return(cur);
3231 * @cur: the child node
3234 * merging adjacent TEXT nodes (in which case @cur is freed)
3241 xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
3252 if (cur == NULL) {
3260 if (parent == cur) {
3263 "xmlAddChild : parent == cur\n");
3268 * If cur is a TEXT node, merge its content with adjacent TEXT nodes
3269 * cur is then freed.
3271 if (cur->type == XML_TEXT_NODE) {
3274 (parent->name == cur->name)) {
3275 xmlNodeAddContent(parent, cur->content);
3276 xmlFreeNode(cur);
3280 (parent->last->name == cur->name) &&
3281 (parent->last != cur)) {
3282 xmlNodeAddContent(parent->last, cur->content);
3283 xmlFreeNode(cur);
3291 prev = cur->parent;
3292 cur->parent = parent;
3293 if (cur->doc != parent->doc) {
3294 xmlSetTreeDoc(cur, parent->doc);
3300 return(cur);
3307 (parent != cur)) {
3308 xmlNodeAddContent(parent, cur->content);
3309 xmlFreeNode(cur);
3312 if (cur->type == XML_ATTRIBUTE_NODE) {
3319 if (cur->ns == NULL)
3320 lastattr = xmlHasNsProp(parent, cur->name, NULL);
3322 lastattr = xmlHasNsProp(parent, cur->name, cur->ns->href);
3323 if ((lastattr != NULL) && (lastattr != (xmlAttrPtr) cur) && (lastattr->type != XML_ATTRIBUTE_DECL)) {
3328 if (lastattr == (xmlAttrPtr) cur)
3329 return(cur);
3333 parent->properties = (xmlAttrPtr) cur;
3340 lastattr->next = (xmlAttrPtr) cur;
3341 ((xmlAttrPtr) cur)->prev = lastattr;
3345 parent->children = cur;
3346 parent->last = cur;
3349 prev->next = cur;
3350 cur->prev = prev;
3351 parent->last = cur;
3354 return(cur);
3396 xmlNodePtr cur = NULL;
3405 cur = parent->children;
3410 while (cur != NULL) {
3411 if (cur->type == XML_ELEMENT_NODE)
3413 cur = cur->next;
3431 xmlNodePtr cur = NULL;
3440 cur = parent->children;
3445 while (cur != NULL) {
3446 if (cur->type == XML_ELEMENT_NODE)
3447 return(cur);
3448 cur = cur->next;
3466 xmlNodePtr cur = NULL;
3475 cur = parent->last;
3480 while (cur != NULL) {
3481 if (cur->type == XML_ELEMENT_NODE)
3482 return(cur);
3483 cur = cur->prev;
3571 * @cur: the first node in the list
3577 xmlFreeNodeList(xmlNodePtr cur) {
3581 if (cur == NULL) return;
3582 if (cur->type == XML_NAMESPACE_DECL) {
3583 xmlFreeNsList((xmlNsPtr) cur);
3586 if ((cur->type == XML_DOCUMENT_NODE) ||
3588 (cur->type == XML_DOCB_DOCUMENT_NODE) ||
3590 (cur->type == XML_HTML_DOCUMENT_NODE)) {
3591 xmlFreeDoc((xmlDocPtr) cur);
3594 if (cur->doc != NULL) dict = cur->doc->dict;
3595 while (cur != NULL) {
3596 next = cur->next;
3597 if (cur->type != XML_DTD_NODE) {
3600 xmlDeregisterNodeDefaultValue(cur);
3602 if ((cur->children != NULL) &&
3603 (cur->type != XML_ENTITY_REF_NODE))
3604 xmlFreeNodeList(cur->children);
3605 if (((cur->type == XML_ELEMENT_NODE) ||
3606 (cur->type == XML_XINCLUDE_START) ||
3607 (cur->type == XML_XINCLUDE_END)) &&
3608 (cur->properties != NULL))
3609 xmlFreePropList(cur->properties);
3610 if ((cur->type != XML_ELEMENT_NODE) &&
3611 (cur->type != XML_XINCLUDE_START) &&
3612 (cur->type != XML_XINCLUDE_END) &&
3613 (cur->type != XML_ENTITY_REF_NODE) &&
3614 (cur->content != (xmlChar *) &(cur->properties))) {
3615 DICT_FREE(cur->content)
3617 if (((cur->type == XML_ELEMENT_NODE) ||
3618 (cur->type == XML_XINCLUDE_START) ||
3619 (cur->type == XML_XINCLUDE_END)) &&
3620 (cur->nsDef != NULL))
3621 xmlFreeNsList(cur->nsDef);
3629 if ((cur->name != NULL) &&
3630 (cur->type != XML_TEXT_NODE) &&
3631 (cur->type != XML_COMMENT_NODE))
3632 DICT_FREE(cur->name)
3633 xmlFree(cur);
3635 cur = next;
3641 * @cur: the node
3647 xmlFreeNode(xmlNodePtr cur) {
3650 if (cur == NULL) return;
3653 if (cur->type == XML_DTD_NODE) {
3654 xmlFreeDtd((xmlDtdPtr) cur);
3657 if (cur->type == XML_NAMESPACE_DECL) {
3658 xmlFreeNs((xmlNsPtr) cur);
3661 if (cur->type == XML_ATTRIBUTE_NODE) {
3662 xmlFreeProp((xmlAttrPtr) cur);
3667 xmlDeregisterNodeDefaultValue(cur);
3669 if (cur->doc != NULL) dict = cur->doc->dict;
3671 if (cur->type == XML_ENTITY_DECL) {
3672 xmlEntityPtr ent = (xmlEntityPtr) cur;
3676 if ((cur->children != NULL) &&
3677 (cur->type != XML_ENTITY_REF_NODE))
3678 xmlFreeNodeList(cur->children);
3679 if (((cur->type == XML_ELEMENT_NODE) ||
3680 (cur->type == XML_XINCLUDE_START) ||
3681 (cur->type == XML_XINCLUDE_END)) &&
3682 (cur->properties != NULL))
3683 xmlFreePropList(cur->properties);
3684 if ((cur->type != XML_ELEMENT_NODE) &&
3685 (cur->content != NULL) &&
3686 (cur->type != XML_ENTITY_REF_NODE) &&
3687 (cur->type != XML_XINCLUDE_END) &&
3688 (cur->type != XML_XINCLUDE_START) &&
3689 (cur->content != (xmlChar *) &(cur->properties))) {
3690 DICT_FREE(cur->content)
3698 if ((cur->name != NULL) &&
3699 (cur->type != XML_TEXT_NODE) &&
3700 (cur->type != XML_COMMENT_NODE))
3701 DICT_FREE(cur->name)
3703 if (((cur->type == XML_ELEMENT_NODE) ||
3704 (cur->type == XML_XINCLUDE_START) ||
3705 (cur->type == XML_XINCLUDE_END)) &&
3706 (cur->nsDef != NULL))
3707 xmlFreeNsList(cur->nsDef);
3708 xmlFree(cur);
3713 * @cur: the node
3718 xmlUnlinkNode(xmlNodePtr cur) {
3719 if (cur == NULL) {
3726 if (cur->type == XML_DTD_NODE) {
3728 doc = cur->doc;
3730 if (doc->intSubset == (xmlDtdPtr) cur)
3732 if (doc->extSubset == (xmlDtdPtr) cur)
3736 if (cur->type == XML_ENTITY_DECL) {
3738 doc = cur->doc;
3741 if (xmlHashLookup(doc->intSubset->entities, cur->name) == cur)
3742 xmlHashRemoveEntry(doc->intSubset->entities, cur->name,
3744 if (xmlHashLookup(doc->intSubset->pentities, cur->name) == cur)
3745 xmlHashRemoveEntry(doc->intSubset->pentities, cur->name,
3749 if (xmlHashLookup(doc->extSubset->entities, cur->name) == cur)
3750 xmlHashRemoveEntry(doc->extSubset->entities, cur->name,
3752 if (xmlHashLookup(doc->extSubset->pentities, cur->name) == cur)
3753 xmlHashRemoveEntry(doc->extSubset->pentities, cur->name,
3758 if (cur->parent != NULL) {
3760 parent = cur->parent;
3761 if (cur->type == XML_ATTRIBUTE_NODE) {
3762 if (parent->properties == (xmlAttrPtr) cur)
3763 parent->properties = ((xmlAttrPtr) cur)->next;
3765 if (parent->children == cur)
3766 parent->children = cur->next;
3767 if (parent->last == cur)
3768 parent->last = cur->prev;
3770 cur->parent = NULL;
3772 if (cur->next != NULL)
3773 cur->next->prev = cur->prev;
3774 if (cur->prev != NULL)
3775 cur->prev->next = cur->next;
3776 cur->next = cur->prev = NULL;
3783 * @cur: the node
3786 * at the same place. If @cur was already inserted in a document it is
3792 xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
3793 if (old == cur) return(NULL);
3801 if (cur == NULL) {
3805 if (cur == old) {
3808 if ((old->type==XML_ATTRIBUTE_NODE) && (cur->type!=XML_ATTRIBUTE_NODE)) {
3815 if ((cur->type==XML_ATTRIBUTE_NODE) && (old->type!=XML_ATTRIBUTE_NODE)) {
3822 xmlUnlinkNode(cur);
3823 xmlSetTreeDoc(cur, old->doc);
3824 cur->parent = old->parent;
3825 cur->next = old->next;
3826 if (cur->next != NULL)
3827 cur->next->prev = cur;
3828 cur->prev = old->prev;
3829 if (cur->prev != NULL)
3830 cur->prev->next = cur;
3831 if (cur->parent != NULL) {
3832 if (cur->type == XML_ATTRIBUTE_NODE) {
3833 if (cur->parent->properties == (xmlAttrPtr)old)
3834 cur->parent->properties = ((xmlAttrPtr) cur);
3836 if (cur->parent->children == old)
3837 cur->parent->children = cur;
3838 if (cur->parent->last == old)
3839 cur->parent->last = cur;
3856 * @cur: the namespace
3863 xmlCopyNamespace(xmlNsPtr cur) {
3866 if (cur == NULL) return(NULL);
3867 switch (cur->type) {
3869 ret = xmlNewNs(NULL, cur->href, cur->prefix);
3874 "xmlCopyNamespace: invalid type %d\n", cur->type);
3883 * @cur: the first namespace
3890 xmlCopyNamespaceList(xmlNsPtr cur) {
3894 while (cur != NULL) {
3895 q = xmlCopyNamespace(cur);
3902 cur = cur->next;
3911 xmlCopyPropInternal(xmlDocPtr doc, xmlNodePtr target, xmlAttrPtr cur) {
3914 if (cur == NULL) return(NULL);
3916 ret = xmlNewDocProp(target->doc, cur->name, NULL);
3918 ret = xmlNewDocProp(doc, cur->name, NULL);
3919 else if (cur->parent != NULL)
3920 ret = xmlNewDocProp(cur->parent->doc, cur->name, NULL);
3921 else if (cur->children != NULL)
3922 ret = xmlNewDocProp(cur->children->doc, cur->name, NULL);
3924 ret = xmlNewDocProp(NULL, cur->name, NULL);
3928 if ((cur->ns != NULL) && (target != NULL)) {
3931 ns = xmlSearchNs(target->doc, target, cur->ns->prefix);
3938 ns = xmlSearchNs(cur->doc, cur->parent, cur->ns->prefix);
3959 if (xmlStrEqual(ns->href, cur->ns->href)) {
3967 ret->ns = xmlNewReconciliedNs(target->doc, target, cur->ns);
3974 if (cur->children != NULL) {
3977 ret->children = xmlStaticCopyNodeList(cur->children, ret->doc, (xmlNodePtr) ret);
3990 if ((target!= NULL) && (cur!= NULL) &&
3991 (target->doc != NULL) && (cur->doc != NULL) &&
3992 (cur->doc->ids != NULL) && (cur->parent != NULL)) {
3993 if (xmlIsID(cur->doc, cur->parent, cur)) {
3996 id = xmlNodeListGetString(cur->doc, cur->children, 1);
4009 * @cur: the attribute
4016 xmlCopyProp(xmlNodePtr target, xmlAttrPtr cur) {
4017 return xmlCopyPropInternal(NULL, target, cur);
4023 * @cur: the first attribute
4030 xmlCopyPropList(xmlNodePtr target, xmlAttrPtr cur) {
4034 while (cur != NULL) {
4035 q = xmlCopyProp(target, cur);
4045 cur = cur->next;
4336 xmlNodePtr cur, p = NULL, q;
4357 cur = dtd->children;
4358 while (cur != NULL) {
4361 if (cur->type == XML_ENTITY_DECL) {
4362 xmlEntityPtr tmp = (xmlEntityPtr) cur;
4377 } else if (cur->type == XML_ELEMENT_DECL) {
4378 xmlElementPtr tmp = (xmlElementPtr) cur;
4381 } else if (cur->type == XML_ATTRIBUTE_DECL) {
4382 xmlAttributePtr tmp = (xmlAttributePtr) cur;
4385 } else if (cur->type == XML_COMMENT_NODE) {
4386 q = xmlCopyNode(cur, 0);
4390 cur = cur->next;
4404 cur = cur->next;
4521 xmlNodePtr cur, tmp, next;
4547 cur = node;
4552 if ((cur->type == XML_DOCUMENT_NODE) ||
4553 (cur->type == XML_HTML_DOCUMENT_NODE)) {
4558 } else if (cur->type == XML_ELEMENT_NODE) {
4561 name = (const char *) cur->name;
4562 if (cur->ns) {
4563 if (cur->ns->prefix != NULL) {
4565 (char *)cur->ns->prefix, (char *)cur->name);
4577 next = cur->parent;
4583 tmp = cur->prev;
4587 (xmlStrEqual(cur->name, tmp->name) &&
4588 ((tmp->ns == cur->ns) ||
4589 ((tmp->ns != NULL) && (cur->ns != NULL) &&
4590 (xmlStrEqual(cur->ns->prefix, tmp->ns->prefix)))))))
4595 tmp = cur->next;
4599 (xmlStrEqual(cur->name, tmp->name) &&
4600 ((tmp->ns == cur->ns) ||
4601 ((tmp->ns != NULL) && (cur->ns != NULL) &&
4602 (xmlStrEqual(cur->ns->prefix, tmp->ns->prefix)))))))
4610 } else if (cur->type == XML_COMMENT_NODE) {
4613 next = cur->parent;
4618 tmp = cur->prev;
4625 tmp = cur->next;
4635 } else if ((cur->type == XML_TEXT_NODE) ||
4636 (cur->type == XML_CDATA_SECTION_NODE)) {
4639 next = cur->parent;
4644 tmp = cur->prev;
4656 tmp = cur->next;
4668 } else if (cur->type == XML_PI_NODE) {
4671 "processing-instruction('%s')", (char *)cur->name);
4675 next = cur->parent;
4680 tmp = cur->prev;
4683 (xmlStrEqual(cur->name, tmp->name)))
4688 tmp = cur->next;
4691 (xmlStrEqual(cur->name, tmp->name)))
4700 } else if (cur->type == XML_ATTRIBUTE_NODE) {
4702 name = (const char *) (((xmlAttrPtr) cur)->name);
4703 if (cur->ns) {
4704 if (cur->ns->prefix != NULL)
4706 (char *)cur->ns->prefix, (char *)cur->name);
4709 (char *)cur->name);
4713 next = ((xmlAttrPtr) cur)->parent;
4715 next = cur->parent;
4748 cur = next;
4749 } while (cur != NULL);
4823 * @cur: the node being changed
4830 xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) {
4833 if (cur == NULL) return;
4834 switch(cur->type) {
4861 ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
4864 xmlSetNsProp(cur, ns, BAD_CAST "lang", lang);
4870 * @cur: the node being checked
4879 xmlNodeGetLang(xmlNodePtr cur) {
4882 while (cur != NULL) {
4883 lang = xmlGetNsProp(cur, BAD_CAST "lang", XML_XML_NAMESPACE);
4886 cur = cur->parent;
4895 * @cur: the node being changed
4902 xmlNodeSetSpacePreserve(xmlNodePtr cur, int val) {
4905 if (cur == NULL) return;
4906 switch(cur->type) {
4933 ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
4938 xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "default");
4941 xmlSetNsProp(cur, ns, BAD_CAST "space", BAD_CAST "preserve");
4949 * @cur: the node being checked
4958 xmlNodeGetSpacePreserve(xmlNodePtr cur) {
4961 while (cur != NULL) {
4962 space = xmlGetNsProp(cur, BAD_CAST "space", XML_XML_NAMESPACE);
4974 cur = cur->parent;
4982 * @cur: the node being changed
4988 xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) {
4992 if (cur == NULL) return;
4994 switch(cur->type) {
5021 doc = cur->doc;
5027 if ((cur->name != NULL) && (!xmlDictOwns(dict, cur->name)))
5028 xmlFree((xmlChar *) cur->name);
5029 cur->name = xmlDictLookup(dict, name, -1);
5031 if (cur->name != NULL) xmlFree((xmlChar *) cur->name);
5032 cur->name = xmlStrdup(name);
5040 * @cur: the node being changed
5047 xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) {
5051 if (cur == NULL) return;
5052 switch(cur->type) {
5078 xmlDocPtr doc = (xmlDocPtr) cur;
5090 ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
5095 xmlSetNsProp(cur, ns, BAD_CAST "base", fixed);
5098 xmlSetNsProp(cur, ns, BAD_CAST "base", uri);
5106 * @cur: the node being checked
5121 xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr cur) {
5125 if ((cur == NULL) && (doc == NULL))
5127 if (doc == NULL) doc = cur->doc;
5129 cur = doc->children;
5130 while ((cur != NULL) && (cur->name != NULL)) {
5131 if (cur->type != XML_ELEMENT_NODE) {
5132 cur = cur->next;
5135 if (!xmlStrcasecmp(cur->name, BAD_CAST "html")) {
5136 cur = cur->children;
5139 if (!xmlStrcasecmp(cur->name, BAD_CAST "head")) {
5140 cur = cur->children;
5143 if (!xmlStrcasecmp(cur->name, BAD_CAST "base")) {
5144 return(xmlGetProp(cur, BAD_CAST "href"));
5146 cur = cur->next;
5150 while (cur != NULL) {
5151 if (cur->type == XML_ENTITY_DECL) {
5152 xmlEntityPtr ent = (xmlEntityPtr) cur;
5155 if (cur->type == XML_ELEMENT_NODE) {
5156 base = xmlGetNsProp(cur, BAD_CAST "base", XML_XML_NAMESPACE);
5178 cur = cur->parent;
5193 * @cur: the node being read
5195 * Read the value of a node @cur, this can be either the text carried
5204 xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
5206 if ((cur == NULL) || (buffer == NULL)) return(-1);
5207 switch (cur->type) {
5210 xmlBufferCat(buffer, cur->content);
5214 xmlNodePtr tmp = cur;
5238 if (tmp == cur)
5250 if (tmp == cur) {
5263 xmlAttrPtr attr = (xmlAttrPtr) cur;
5277 xmlBufferCat(buffer, cur->content);
5284 ent = xmlGetDocEntity(cur->doc, cur->name);
5312 cur = cur->children;
5313 while (cur!= NULL) {
5314 if ((cur->type == XML_ELEMENT_NODE) ||
5315 (cur->type == XML_TEXT_NODE) ||
5316 (cur->type == XML_CDATA_SECTION_NODE)) {
5317 xmlNodeBufGetContent(buffer, cur);
5319 cur = cur->next;
5323 xmlBufferCat(buffer, ((xmlNsPtr) cur)->href);
5334 * @cur: the node being read
5344 xmlNodeGetContent(xmlNodePtr cur)
5346 if (cur == NULL)
5348 switch (cur->type) {
5357 xmlNodeBufGetContent(buffer, cur);
5364 return(xmlGetPropNodeValueInternal((xmlAttrPtr) cur));
5367 if (cur->content != NULL)
5368 return (xmlStrdup(cur->content));
5376 ent = xmlGetDocEntity(cur->doc, cur->name);
5384 xmlNodeBufGetContent(buffer, cur);
5410 xmlNodeBufGetContent(buffer, (xmlNodePtr) cur);
5420 tmp = xmlStrdup(((xmlNsPtr) cur)->href);
5434 if (cur->content != NULL)
5435 return (xmlStrdup(cur->content));
5443 * @cur: the node being modified
5452 xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) {
5453 if (cur == NULL) {
5460 switch (cur->type) {
5464 if (cur->children != NULL) xmlFreeNodeList(cur->children);
5465 cur->children = xmlStringGetNodeList(cur->doc, content);
5466 UPDATE_LAST_CHILD_AND_PARENT(cur)
5474 if ((cur->content != NULL) &&
5475 (cur->content != (xmlChar *) &(cur->properties))) {
5476 if (!((cur->doc != NULL) && (cur->doc->dict != NULL) &&
5477 (xmlDictOwns(cur->doc->dict, cur->content))))
5478 xmlFree(cur->content);
5480 if (cur->children != NULL) xmlFreeNodeList(cur->children);
5481 cur->last = cur->children = NULL;
5483 cur->content = xmlStrdup(content);
5485 cur->content = NULL;
5486 cur->properties = NULL;
5487 cur->nsDef = NULL;
5519 * @cur: the node being modified
5529 xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
5530 if (cur == NULL) {
5537 switch (cur->type) {
5541 if (cur->children != NULL) xmlFreeNodeList(cur->children);
5542 cur->children = xmlStringLenGetNodeList(cur->doc, content, len);
5543 UPDATE_LAST_CHILD_AND_PARENT(cur)
5552 if ((cur->content != NULL) &&
5553 (cur->content != (xmlChar *) &(cur->properties))) {
5554 if (!((cur->doc != NULL) && (cur->doc->dict != NULL) &&
5555 (xmlDictOwns(cur->doc->dict, cur->content))))
5556 xmlFree(cur->content);
5558 if (cur->children != NULL) xmlFreeNodeList(cur->children);
5559 cur->children = cur->last = NULL;
5561 cur->content = xmlStrndup(content, len);
5563 cur->content = NULL;
5564 cur->properties = NULL;
5565 cur->nsDef = NULL;
5593 * @cur: the node being modified
5603 xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
5604 if (cur == NULL) {
5612 switch (cur->type) {
5617 last = cur->last;
5620 cur, newNode);
5639 if ((cur->content == (xmlChar *) &(cur->properties)) ||
5640 ((cur->doc != NULL) && (cur->doc->dict != NULL) &&
5641 xmlDictOwns(cur->doc->dict, cur->content))) {
5642 cur->content = xmlStrncatNew(cur->content, content, len);
5643 cur->properties = NULL;
5644 cur->nsDef = NULL;
5647 cur->content = xmlStrncat(cur->content, content, len);
5669 * @cur: the node being modified
5678 xmlNodeAddContent(xmlNodePtr cur, const xmlChar *content) {
5681 if (cur == NULL) {
5690 xmlNodeAddContentLen(cur, content, len);
5729 xmlNsPtr cur;
5737 cur = node->nsDef;
5738 while (cur != NULL) {
5750 if ((cur->prefix == ret[i]->prefix) ||
5751 (xmlStrEqual(cur->prefix, ret[i]->prefix)))
5766 ret[nbns++] = cur;
5770 cur = cur->next;
5830 xmlNsPtr cur;
5842 cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
5843 if (cur == NULL) {
5847 memset(cur, 0, sizeof(xmlNs));
5848 cur->type = XML_LOCAL_NAMESPACE;
5849 cur->href = xmlStrdup(XML_XML_NAMESPACE);
5850 cur->prefix = xmlStrdup((const xmlChar *)"xml");
5851 cur->next = node->nsDef;
5852 node->nsDef = cur;
5853 return(cur);
5874 cur = node->nsDef;
5875 while (cur != NULL) {
5876 if ((cur->prefix == NULL) && (nameSpace == NULL) &&
5877 (cur->href != NULL))
5878 return(cur);
5879 if ((cur->prefix != NULL) && (nameSpace != NULL) &&
5880 (cur->href != NULL) &&
5881 (xmlStrEqual(cur->prefix, nameSpace)))
5882 return(cur);
5883 cur = cur->next;
5886 cur = node->ns;
5887 if (cur != NULL) {
5888 if ((cur->prefix == NULL) && (nameSpace == NULL) &&
5889 (cur->href != NULL))
5890 return(cur);
5891 if ((cur->prefix != NULL) && (nameSpace != NULL) &&
5892 (cur->href != NULL) &&
5893 (xmlStrEqual(cur->prefix, nameSpace)))
5894 return(cur);
5959 xmlNsPtr cur;
5975 cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
5976 if (cur == NULL) {
5980 memset(cur, 0, sizeof(xmlNs));
5981 cur->type = XML_LOCAL_NAMESPACE;
5982 cur->href = xmlStrdup(XML_XML_NAMESPACE);
5983 cur->prefix = xmlStrdup((const xmlChar *) "xml");
5984 cur->next = node->nsDef;
5985 node->nsDef = cur;
5986 return (cur);
6008 cur = node->nsDef;
6009 while (cur != NULL) {
6010 if ((cur->href != NULL) && (href != NULL) &&
6011 (xmlStrEqual(cur->href, href))) {
6012 if (((!is_attr) || (cur->prefix != NULL)) &&
6013 (xmlNsInScope(doc, orig, node, cur->prefix) == 1))
6014 return (cur);
6016 cur = cur->next;
6019 cur = node->ns;
6020 if (cur != NULL) {
6021 if ((cur->href != NULL) && (href != NULL) &&
6022 (xmlStrEqual(cur->href, href))) {
6023 if (((!is_attr) || (cur->prefix != NULL)) &&
6024 (xmlNsInScope(doc, orig, node, cur->prefix) == 1))
6025 return (cur);
6371 xmlNsPtr *nsList, *cur;
6383 cur = nsList;
6384 while (*cur != NULL) {
6385 if (xmlStrEqual((*cur)->href, nsName)) {
6387 name, (*cur)->prefix);
6392 name, (*cur)->prefix);
6397 cur++;
6770 const xmlChar *cur;
6777 cur = node->content;
6778 while (*cur != 0) {
6779 if (!IS_BLANK_CH(*cur)) return(0);
6780 cur++;
7410 const char *cur;
7422 for (cur = str;*cur != 0;cur++) {
7429 buf->content[buf->use++] = *cur;
7479 const xmlChar *cur, *base;
7490 base = cur = string;
7491 while(*cur != 0){
7492 if(*cur == '"'){
7493 if (base != cur)
7494 xmlBufferAdd(buf, base, cur - base);
7496 cur++;
7497 base = cur;
7500 cur++;
7503 if (base != cur)
7504 xmlBufferAdd(buf, base, cur - base);
7626 xmlNsMapItemPtr cur, tmp;
7630 cur = nsmap->pool;
7631 while (cur != NULL) {
7632 tmp = cur;
7633 cur = cur->next;
7636 cur = nsmap->first;
7637 while (cur != NULL) {
7638 tmp = cur;
7639 cur = cur->next;
7855 xmlNodePtr cur;
7865 cur = node;
7866 while ((cur != NULL) && (cur != (xmlNodePtr) cur->doc)) {
7867 if (cur->type == XML_ELEMENT_NODE) {
7868 if (cur->nsDef != NULL) {
7869 ns = cur->nsDef;
7897 cur = cur->parent;
7927 xmlDictOwns(sourceDoc->dict, cur->content)) { \
7929 cur->content = (xmlChar *) \
7930 xmlDictLookup(destDoc->dict, cur->content, -1); \
7932 cur->content = xmlStrdup(BAD_CAST cur->content); \
8124 xmlNodePtr cur, prev = NULL, out = NULL;
8137 cur = node;
8139 if (cur->type == XML_ELEMENT_NODE) {
8140 if (cur->nsDef != NULL) {
8141 for (ns = cur->nsDef; ns != NULL; ns = ns->next) {
8196 prev = cur;
8198 } else if ((cur->type == XML_ENTITY_NODE) ||
8199 (cur->type == XML_ENTITY_DECL))
8201 cur = cur->parent;
8202 } while ((cur != NULL) && (cur->doc != (xmlDocPtr) cur));
8224 xmlNodePtr cur;
8240 cur = node;
8242 if (cur->type == XML_ELEMENT_NODE) {
8243 if (cur->nsDef != NULL) {
8244 ns = cur->nsDef;
8261 } else if ((cur->type == XML_ENTITY_NODE) ||
8262 (cur->type == XML_ENTITY_DECL))
8264 cur = cur->parent;
8265 } while ((cur != NULL) && (cur->doc != (xmlDocPtr) cur));
8510 xmlNodePtr cur, curElem = NULL;
8525 cur = elem;
8527 switch (cur->type) {
8530 curElem = cur;
8535 if (cur->nsDef != NULL) {
8537 ns = cur->nsDef;
8577 cur->nsDef = ns->next;
8587 if ((cur->ns != NULL) && adoptns && (cur->ns == ns))
8620 if (cur->ns == NULL)
8637 if (cur->ns == listRedund[j]) {
8638 cur->ns = listRedund[++j];
8652 (cur->ns == mi->oldNs)) {
8654 cur->ns = mi->newNs;
8663 cur->ns, &ns,
8666 (cur->type == XML_ATTRIBUTE_NODE) ? 1 : 0) == -1)
8668 cur->ns = ns;
8671 if ((cur->type == XML_ELEMENT_NODE) &&
8672 (cur->properties != NULL)) {
8676 cur = (xmlNodePtr) cur->properties;
8684 if ((cur->type == XML_ELEMENT_NODE) &&
8685 (cur->children != NULL)) {
8689 cur = cur->children;
8693 if (cur == elem)
8695 if (cur->type == XML_ELEMENT_NODE) {
8715 if (cur->next != NULL)
8716 cur = cur->next;
8718 if (cur->type == XML_ATTRIBUTE_NODE) {
8719 cur = cur->parent;
8722 cur = cur->parent;
8725 } while (cur != NULL);
8774 xmlNodePtr cur, curElem = NULL;
8811 cur = node;
8812 while (cur != NULL) {
8816 if (cur->doc != sourceDoc) {
8823 if (cur->next == NULL)
8826 cur = cur->next;
8827 if ((cur->type == XML_XINCLUDE_END) ||
8828 (cur->doc == node->doc))
8830 } while (cur->next != NULL);
8832 if (cur->doc != node->doc)
8835 cur->doc = destDoc;
8836 switch (cur->type) {
8844 curElem = cur;
8854 if ((cur->nsDef) &&
8866 for (ns = cur->nsDef; ns != NULL; ns = ns->next) {
8898 if (cur->ns == NULL)
8916 (cur->ns == mi->oldNs)) {
8918 cur->ns = mi->newNs;
8930 ns = ctxt->getNsForNodeFunc(ctxt, cur,
8931 cur->ns->href, cur->ns->prefix);
8937 cur->ns, ns, XML_TREE_NSMAP_CUSTOM) == NULL)
8939 cur->ns = ns;
8947 cur->ns, &ns,
8951 (cur->type == XML_ATTRIBUTE_NODE) ? 1 : 0) == -1)
8953 cur->ns = ns;
8960 XML_TREE_ADOPT_STR(cur->name)
8961 if (cur->type == XML_ELEMENT_NODE) {
8962 cur->psvi = NULL;
8963 cur->line = 0;
8964 cur->extra = 0;
8968 if (cur->properties != NULL) {
8972 cur = (xmlNodePtr) cur->properties;
8980 (((xmlAttrPtr) cur)->atype == XML_ATTRIBUTE_ID))
8982 xmlRemoveID(sourceDoc, (xmlAttrPtr) cur);
8984 ((xmlAttrPtr) cur)->atype = 0;
8985 ((xmlAttrPtr) cur)->psvi = NULL;
8994 XML_TREE_ADOPT_STR_2(cur->content)
9000 cur->content = NULL;
9001 cur->children = NULL;
9002 cur->last = NULL;
9008 ent = xmlGetDocEntity(destDoc, cur->name);
9010 cur->content = ent->content;
9011 cur->children = (xmlNodePtr) ent;
9012 cur->last = (xmlNodePtr) ent;
9017 XML_TREE_ADOPT_STR(cur->name)
9018 XML_TREE_ADOPT_STR_2(cur->content)
9028 if (cur->children != NULL) {
9029 cur = cur->children;
9034 if (cur == node)
9036 if ((cur->type == XML_ELEMENT_NODE) ||
9037 (cur->type == XML_XINCLUDE_START) ||
9038 (cur->type == XML_XINCLUDE_END))
9062 if (cur->next != NULL)
9063 cur = cur->next;
9064 else if ((cur->type == XML_ATTRIBUTE_NODE) &&
9065 (cur->parent->children != NULL))
9067 cur = cur->parent->children;
9069 cur = cur->parent;
9141 xmlNodePtr cur, curElem = NULL;
9190 cur = node;
9191 while (cur != NULL) {
9192 if (cur->doc != sourceDoc) {
9203 switch (cur->type) {
9273 clone->type = cur->type;
9279 if (cur->name == xmlStringText)
9281 else if (cur->name == xmlStringTextNoenc)
9288 else if (cur->name == xmlStringComment)
9290 else if (cur->name != NULL) {
9291 DICT_CONST_COPY(cur->name, clone->name);
9294 switch (cur->type) {
9302 curElem = cur;
9307 if (cur->nsDef != NULL) {
9323 for (ns = cur->nsDef; ns != NULL; ns = ns->next) {
9379 /* cur->ns will be processed further down. */
9383 /* cur->ns will be processed further down. */
9390 DICT_COPY(cur->content, clone->content);
9402 ent = xmlGetDocEntity(destDoc, cur->name);
9414 clone->content = cur->content;
9415 clone->children = cur->children;
9416 clone->last = cur->last;
9420 DICT_COPY(cur->content, clone->content);
9423 DICT_COPY(cur->content, clone->content);
9429 if (cur->ns == NULL)
9454 (cur->ns == mi->oldNs)) {
9470 ns = ctxt->getNsForNodeFunc(ctxt, cur,
9471 cur->ns->href, cur->ns->prefix);
9476 cur->ns, ns, XML_TREE_NSMAP_CUSTOM) == NULL)
9486 cur->ns, &ns,
9491 (cur->type == XML_ATTRIBUTE_NODE) ? 1 : 0) == -1)
9510 idVal = xmlNodeListGetString(cur->doc, cur->children, 1);
9512 if (xmlAddID(NULL, destDoc, idVal, (xmlAttrPtr) cur) == NULL) {
9528 if ((cur->type == XML_ELEMENT_NODE) && (cur->properties != NULL)) {
9531 cur = (xmlNodePtr) cur->properties;
9538 if (cur->children != NULL) {
9539 if (deep || (cur->type == XML_ATTRIBUTE_NODE)) {
9542 cur = cur->children;
9552 if (cur == node)
9554 if ((cur->type == XML_ELEMENT_NODE) ||
9555 (cur->type == XML_XINCLUDE_START) ||
9556 (cur->type == XML_XINCLUDE_END)) {
9579 if (cur->next != NULL) {
9581 cur = cur->next;
9582 } else if (cur->type != XML_ATTRIBUTE_NODE) {
9593 cur = cur->parent;
9602 cur = cur->parent;
9661 xmlNodePtr cur;
9707 cur = attr->children;
9708 while (cur != NULL) {
9709 cur->doc = destDoc;
9710 switch (cur->type) {
9713 XML_TREE_ADOPT_STR_2(cur->content)
9719 cur->content = NULL;
9720 cur->children = NULL;
9721 cur->last = NULL;
9727 ent = xmlGetDocEntity(destDoc, cur->name);
9729 cur->content = ent->content;
9730 cur->children = (xmlNodePtr) ent;
9731 cur->last = (xmlNodePtr) ent;
9738 if (cur->children != NULL) {
9739 cur = cur->children;
9743 if (cur == (xmlNodePtr) attr)
9745 if (cur->next != NULL)
9746 cur = cur->next;
9748 cur = cur->parent;
9837 xmlNodePtr cur = node;
9840 cur->doc = destDoc;