* xmlXPathRunStreamEval: * @pctxt: the XPath parser context with the compiled expression * * Evaluate the Precompiled Streamable XPath expression in the given context. */
| 12455 | * Evaluate the Precompiled Streamable XPath expression in the given context. |
| 12456 | */ |
| 12457 | static int |
| 12458 | xmlXPathRunStreamEval(xmlXPathParserContextPtr pctxt, xmlPatternPtr comp, |
| 12459 | xmlXPathObjectPtr *resultSeq, int toBool) |
| 12460 | { |
| 12461 | int max_depth, min_depth; |
| 12462 | int from_root; |
| 12463 | int ret, depth; |
| 12464 | int eval_all_nodes; |
| 12465 | xmlNodePtr cur = NULL, limit = NULL; |
| 12466 | xmlStreamCtxtPtr patstream = NULL; |
| 12467 | xmlXPathContextPtr ctxt = pctxt->context; |
| 12468 | |
| 12469 | if ((ctxt == NULL) || (comp == NULL)) |
| 12470 | return(-1); |
| 12471 | max_depth = xmlPatternMaxDepth(comp); |
| 12472 | if (max_depth == -1) |
| 12473 | return(-1); |
| 12474 | if (max_depth == -2) |
| 12475 | max_depth = 10000; |
| 12476 | min_depth = xmlPatternMinDepth(comp); |
| 12477 | if (min_depth == -1) |
| 12478 | return(-1); |
| 12479 | from_root = xmlPatternFromRoot(comp); |
| 12480 | if (from_root < 0) |
| 12481 | return(-1); |
| 12482 | #if 0 |
| 12483 | printf("stream eval: depth %d from root %d\n", max_depth, from_root); |
| 12484 | #endif |
| 12485 | |
| 12486 | if (! toBool) { |
| 12487 | if (resultSeq == NULL) |
| 12488 | return(-1); |
| 12489 | *resultSeq = xmlXPathCacheNewNodeSet(pctxt, NULL); |
| 12490 | if (*resultSeq == NULL) |
| 12491 | return(-1); |
| 12492 | } |
| 12493 | |
| 12494 | /* |
| 12495 | * handle the special cases of "/" amd "." being matched |
| 12496 | */ |
| 12497 | if (min_depth == 0) { |
| 12498 | int res; |
| 12499 | |
| 12500 | if (from_root) { |
| 12501 | /* Select "/" */ |
| 12502 | if (toBool) |
| 12503 | return(1); |
| 12504 | res = xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, |
| 12505 | (xmlNodePtr) ctxt->doc); |
| 12506 | } else { |
| 12507 | /* Select "self::node()" */ |
| 12508 | if (toBool) |
| 12509 | return(1); |
| 12510 | res = xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, |
| 12511 | ctxt->node); |
| 12512 | } |
| 12513 | |
| 12514 | if (res < 0) |
no test coverage detected