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

Function xmlXPathOrderDocElems

ThirdParty/libxml2/vtklibxml2/xpath.c:2458–2493  ·  view source on GitHub ↗

* xmlXPathOrderDocElems: * @doc: an input document * * Call this routine to speed up XPath computation on static documents. * This stamps all the element nodes with the document order * Like for line information, the order is kept in the element->content * field, the value stored is actually - the node number (starting at -1) * to be able to differentiate from line numbers. * * Returns t

Source from the content-addressed store, hash-verified

2456 * of error.
2457 */
2458long
2459xmlXPathOrderDocElems(xmlDocPtr doc) {
2460 ptrdiff_t count = 0;
2461 xmlNodePtr cur;
2462
2463 if (doc == NULL)
2464 return(-1);
2465 cur = doc->children;
2466 while (cur != NULL) {
2467 if (cur->type == XML_ELEMENT_NODE) {
2468 cur->content = (void *) (-(++count));
2469 if (cur->children != NULL) {
2470 cur = cur->children;
2471 continue;
2472 }
2473 }
2474 if (cur->next != NULL) {
2475 cur = cur->next;
2476 continue;
2477 }
2478 do {
2479 cur = cur->parent;
2480 if (cur == NULL)
2481 break;
2482 if (cur == (xmlNodePtr) doc) {
2483 cur = NULL;
2484 break;
2485 }
2486 if (cur->next != NULL) {
2487 cur = cur->next;
2488 break;
2489 }
2490 } while (cur != NULL);
2491 }
2492 return(count);
2493}
2494
2495/**
2496 * xmlXPathCmpNodes:

Callers 1

parseAndPrintFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected