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

Function xmlXPathCompOpEvalFirst

ThirdParty/libxml2/vtklibxml2/xpath.c:11422–11552  ·  view source on GitHub ↗

* xmlXPathCompOpEvalFirst: * @ctxt: the XPath parser context with the compiled expression * @op: an XPath compiled operation * @first: the first elem found so far * * Evaluate the Precompiled XPath operation searching only the first * element in document order * * Returns the number of examined objects. */

Source from the content-addressed store, hash-verified

11420 * Returns the number of examined objects.
11421 */
11422static int
11423xmlXPathCompOpEvalFirst(xmlXPathParserContextPtr ctxt,
11424 xmlXPathStepOpPtr op, xmlNodePtr * first)
11425{
11426 int total = 0, cur;
11427 xmlXPathCompExprPtr comp;
11428 xmlXPathObjectPtr arg1, arg2;
11429
11430 CHECK_ERROR0;
11431 if (OP_LIMIT_EXCEEDED(ctxt, 1))
11432 return(0);
11433 if (ctxt->context->depth >= XPATH_MAX_RECURSION_DEPTH)
11434 XP_ERROR0(XPATH_RECURSION_LIMIT_EXCEEDED);
11435 ctxt->context->depth += 1;
11436 comp = ctxt->comp;
11437 switch (op->op) {
11438 case XPATH_OP_END:
11439 break;
11440 case XPATH_OP_UNION:
11441 total =
11442 xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch1],
11443 first);
11444 CHECK_ERROR0;
11445 if ((ctxt->value != NULL)
11446 && (ctxt->value->type == XPATH_NODESET)
11447 && (ctxt->value->nodesetval != NULL)
11448 && (ctxt->value->nodesetval->nodeNr >= 1)) {
11449 /*
11450 * limit tree traversing to first node in the result
11451 */
11452 /*
11453 * OPTIMIZE TODO: This implicitly sorts
11454 * the result, even if not needed. E.g. if the argument
11455 * of the count() function, no sorting is needed.
11456 * OPTIMIZE TODO: How do we know if the node-list wasn't
11457 * already sorted?
11458 */
11459 if (ctxt->value->nodesetval->nodeNr > 1)
11460 xmlXPathNodeSetSort(ctxt->value->nodesetval);
11461 *first = ctxt->value->nodesetval->nodeTab[0];
11462 }
11463 cur =
11464 xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch2],
11465 first);
11466 CHECK_ERROR0;
11467
11468 arg2 = valuePop(ctxt);
11469 arg1 = valuePop(ctxt);
11470 if ((arg1 == NULL) || (arg1->type != XPATH_NODESET) ||
11471 (arg2 == NULL) || (arg2->type != XPATH_NODESET)) {
11472 xmlXPathReleaseObject(ctxt->context, arg1);
11473 xmlXPathReleaseObject(ctxt->context, arg2);
11474 XP_ERROR0(XPATH_INVALID_TYPE);
11475 }
11476 if ((ctxt->context->opLimit != 0) &&
11477 (((arg1->nodesetval != NULL) &&
11478 (xmlXPathCheckOpLimit(ctxt,
11479 arg1->nodesetval->nodeNr) < 0)) ||

Callers 1

xmlXPathCompOpEvalFunction · 0.85

Calls 14

xmlXPathNodeSetSortFunction · 0.85
valuePopFunction · 0.85
xmlXPathReleaseObjectFunction · 0.85
xmlXPathCheckOpLimitFunction · 0.85
xmlXPathNodeSetMergeFunction · 0.85
xmlXPathPErrMemoryFunction · 0.85
valuePushFunction · 0.85
xmlXPathCompSwapFunction · 0.85
xmlXPathRootFunction · 0.85
xmlXPathCompOpEvalFunction · 0.85
xmlXPathCacheNewNodeSetFunction · 0.85

Tested by

no test coverage detected