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

Function xmlXPtrEvalRangePredicate

ThirdParty/libxml2/vtklibxml2/xpointer.c:2821–2920  ·  view source on GitHub ↗

* xmlXPtrEvalRangePredicate: * @ctxt: the XPointer Parser context * * [8] Predicate ::= '[' PredicateExpr ']' * [9] PredicateExpr ::= Expr * * Evaluate a predicate as in xmlXPathEvalPredicate() but for * a Location Set instead of a node set */

Source from the content-addressed store, hash-verified

2819 * a Location Set instead of a node set
2820 */
2821void
2822xmlXPtrEvalRangePredicate(xmlXPathParserContextPtr ctxt) {
2823 const xmlChar *cur;
2824 xmlXPathObjectPtr res;
2825 xmlXPathObjectPtr obj, tmp;
2826 xmlLocationSetPtr newset = NULL;
2827 xmlLocationSetPtr oldset;
2828 int i;
2829
2830 if (ctxt == NULL) return;
2831
2832 SKIP_BLANKS;
2833 if (CUR != '[') {
2834 XP_ERROR(XPATH_INVALID_PREDICATE_ERROR);
2835 }
2836 NEXT;
2837 SKIP_BLANKS;
2838
2839 /*
2840 * Extract the old set, and then evaluate the result of the
2841 * expression for all the element in the set. use it to grow
2842 * up a new set.
2843 */
2844 CHECK_TYPE(XPATH_LOCATIONSET);
2845 obj = valuePop(ctxt);
2846 oldset = obj->user;
2847 ctxt->context->node = NULL;
2848
2849 if ((oldset == NULL) || (oldset->locNr == 0)) {
2850 ctxt->context->contextSize = 0;
2851 ctxt->context->proximityPosition = 0;
2852 xmlXPathEvalExpr(ctxt);
2853 res = valuePop(ctxt);
2854 if (res != NULL)
2855 xmlXPathFreeObject(res);
2856 valuePush(ctxt, obj);
2857 CHECK_ERROR;
2858 } else {
2859 /*
2860 * Save the expression pointer since we will have to evaluate
2861 * it multiple times. Initialize the new set.
2862 */
2863 cur = ctxt->cur;
2864 newset = xmlXPtrLocationSetCreate(NULL);
2865
2866 for (i = 0; i < oldset->locNr; i++) {
2867 ctxt->cur = cur;
2868
2869 /*
2870 * Run the evaluation with a node list made of a single item
2871 * in the nodeset.
2872 */
2873 ctxt->context->node = oldset->locTab[i]->user;
2874 tmp = xmlXPathNewNodeSet(ctxt->context->node);
2875 valuePush(ctxt, tmp);
2876 ctxt->context->contextSize = oldset->locNr;
2877 ctxt->context->proximityPosition = i + 1;
2878

Callers

nothing calls this directly

Calls 10

valuePopFunction · 0.85
xmlXPathEvalExprFunction · 0.85
xmlXPathFreeObjectFunction · 0.85
valuePushFunction · 0.85
xmlXPathNewNodeSetFunction · 0.85
xmlXPathObjectCopyFunction · 0.85
xmlXPtrLocationSetCreateFunction · 0.70
xmlXPtrLocationSetAddFunction · 0.70
xmlXPtrWrapLocationSetFunction · 0.70

Tested by

no test coverage detected