* 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 */
| 2819 | * a Location Set instead of a node set |
| 2820 | */ |
| 2821 | void |
| 2822 | xmlXPtrEvalRangePredicate(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 |
nothing calls this directly
no test coverage detected