MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlXPtrBuildRangeNodeList

Function xmlXPtrBuildRangeNodeList

ThirdParty/libxml2/vtklibxml2/xpointer.c:1421–1578  ·  view source on GitHub ↗

* xmlXPtrBuildRangeNodeList: * @range: a range object * * Build a node list tree copy of the range * * Returns an xmlNodePtr list or NULL. * the caller has to free the node tree. */

Source from the content-addressed store, hash-verified

1419 * the caller has to free the node tree.
1420 */
1421static xmlNodePtr
1422xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
1423 /* pointers to generated nodes */
1424 xmlNodePtr list = NULL, last = NULL, parent = NULL, tmp;
1425 /* pointers to traversal nodes */
1426 xmlNodePtr start, cur, end;
1427 int index1, index2;
1428
1429 if (range == NULL)
1430 return(NULL);
1431 if (range->type != XPATH_RANGE)
1432 return(NULL);
1433 start = (xmlNodePtr) range->user;
1434
1435 if ((start == NULL) || (start->type == XML_NAMESPACE_DECL))
1436 return(NULL);
1437 end = range->user2;
1438 if (end == NULL)
1439 return(xmlCopyNode(start, 1));
1440 if (end->type == XML_NAMESPACE_DECL)
1441 return(NULL);
1442
1443 cur = start;
1444 index1 = range->index;
1445 index2 = range->index2;
1446 while (cur != NULL) {
1447 if (cur == end) {
1448 if (cur->type == XML_TEXT_NODE) {
1449 const xmlChar *content = cur->content;
1450 int len;
1451
1452 if (content == NULL) {
1453 tmp = xmlNewTextLen(NULL, 0);
1454 } else {
1455 len = index2;
1456 if ((cur == start) && (index1 > 1)) {
1457 content += (index1 - 1);
1458 len -= (index1 - 1);
1459 index1 = 0;
1460 } else {
1461 len = index2;
1462 }
1463 tmp = xmlNewTextLen(content, len);
1464 }
1465 /* single sub text node selection */
1466 if (list == NULL)
1467 return(tmp);
1468 /* prune and return full set */
1469 if (last != NULL)
1470 xmlAddNextSibling(last, tmp);
1471 else
1472 xmlAddChild(parent, tmp);
1473 return(list);
1474 } else {
1475 tmp = xmlCopyNode(cur, 0);
1476 if (list == NULL) {
1477 list = tmp;
1478 parent = tmp;

Callers 1

xmlXPtrBuildNodeListFunction · 0.85

Calls 7

xmlCopyNodeFunction · 0.85
xmlNewTextLenFunction · 0.85
xmlAddNextSiblingFunction · 0.85
xmlAddChildFunction · 0.85
xmlXPtrGetNthChildFunction · 0.85
xmlNewTextFunction · 0.85
xmlXPtrAdvanceNodeFunction · 0.85

Tested by

no test coverage detected