Home | History | Annotate | Download | only in libxml2

Lines Matching refs:ctxt

581     { xmlXPathErr(ctxt, X); return(NULL); }
618 * @ctxt: an XPath context
624 xmlXPathErrMemory(xmlXPathContextPtr ctxt, const char *extra)
626 if (ctxt != NULL) {
633 ctxt->lastError.message = (char *) xmlStrdup(buf);
635 ctxt->lastError.message = (char *)
638 ctxt->lastError.domain = XML_FROM_XPATH;
639 ctxt->lastError.code = XML_ERR_NO_MEMORY;
640 if (ctxt->error != NULL)
641 ctxt->error(ctxt->userData, &ctxt->lastError);
660 * @ctxt: an XPath parser context
666 xmlXPathPErrMemory(xmlXPathParserContextPtr ctxt, const char *extra)
668 if (ctxt == NULL)
671 ctxt->error = XPATH_MEMORY_ERROR;
672 xmlXPathErrMemory(ctxt->context, extra);
678 * @ctxt: a XPath parser context
684 xmlXPathErr(xmlXPathParserContextPtr ctxt, int error)
688 if (ctxt == NULL) {
697 ctxt->error = error;
698 if (ctxt->context == NULL) {
703 (const char *) ctxt->base, NULL, NULL,
704 ctxt->cur - ctxt->base, 0,
710 xmlResetError(&ctxt->context->lastError);
712 ctxt->context->lastError.domain = XML_FROM_XPATH;
713 ctxt->context->lastError.code = error + XML_XPATH_EXPRESSION_OK -
715 ctxt->context->lastError.level = XML_ERR_ERROR;
716 ctxt->context->lastError.str1 = (char *) xmlStrdup(ctxt->base);
717 ctxt->context->lastError.int1 = ctxt->cur - ctxt->base;
718 ctxt->context->lastError.node = ctxt->context->debugNode;
719 if (ctxt->context->error != NULL) {
720 ctxt->context->error(ctxt->context->userData,
721 &ctxt->context->lastError);
724 NULL, ctxt->context->debugNode, XML_FROM_XPATH,
727 (const char *) ctxt->base, NULL, NULL,
728 ctxt->cur - ctxt->base, 0,
736 * @ctxt: the XPath Parser context
744 xmlXPatherror(xmlXPathParserContextPtr ctxt, const char *file ATTRIBUTE_UNUSED,
746 xmlXPathErr(ctxt, no);
955 xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj);
957 xmlXPathCompOpEvalFirst(xmlXPathParserContextPtr ctxt,
960 xmlXPathCompOpEvalToBoolean(xmlXPathParserContextPtr ctxt,
1156 xmlXPathCompExprAdd(ctxt->comp, (op1), (op2), \
1159 xmlXPathCompExprAdd(ctxt->comp, ctxt->comp->last, -1, \
1163 xmlXPathCompExprAdd(ctxt->comp, -1, -1, (op), (val), (val2), 0 ,NULL ,NULL)
1166 xmlXPathCompExprAdd(ctxt->comp, (ch), -1, (op), (val), (val2), 0 ,NULL ,NULL)
1169 xmlXPathCompExprAdd(ctxt->comp, (ch1), (ch2), (op), \
1723 xmlXPathDebugObjUsageReset(xmlXPathContextPtr ctxt)
1725 if (ctxt != NULL) {
1726 if (ctxt->cache != NULL) {
1728 (xmlXPathContextCachePtr) ctxt->cache;
1795 xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
1800 if (ctxt != NULL) {
1801 if (ctxt->cache != NULL) {
1803 (xmlXPathContextCachePtr) ctxt->cache;
1949 xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
1954 if (ctxt != NULL) {
1955 if (ctxt->cache != NULL) {
1957 (xmlXPathContextCachePtr) ctxt->cache;
2038 xmlXPathDebugObjUsageDisplay(xmlXPathContextPtr ctxt)
2058 if (ctxt != NULL) {
2059 if (ctxt->cache != NULL) {
2061 (xmlXPathContextCachePtr) ctxt->cache;
2229 * @ctxt: the XPath context
2249 xmlXPathContextSetCache(xmlXPathContextPtr ctxt,
2254 if (ctxt == NULL)
2259 if (ctxt->cache == NULL) {
2260 ctxt->cache = xmlXPathNewCache();
2261 if (ctxt->cache == NULL)
2264 cache = (xmlXPathContextCachePtr) ctxt->cache;
2274 } else if (ctxt->cache != NULL) {
2275 xmlXPathFreeCache((xmlXPathContextCachePtr) ctxt->cache);
2276 ctxt->cache = NULL;
2283 * @ctxt: the XPath context
2292 xmlXPathCacheWrapNodeSet(xmlXPathContextPtr ctxt, xmlNodeSetPtr val)
2294 if ((ctxt != NULL) && (ctxt->cache != NULL)) {
2296 (xmlXPathContextCachePtr) ctxt->cache;
2308 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
2320 * @ctxt: the XPath context
2329 xmlXPathCacheWrapString(xmlXPathContextPtr ctxt, xmlChar *val)
2331 if ((ctxt != NULL) && (ctxt->cache != NULL)) {
2332 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2345 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2361 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2371 * @ctxt: the XPath context
2381 xmlXPathCacheNewNodeSet(xmlXPathContextPtr ctxt, xmlNodePtr val)
2383 if ((ctxt != NULL) && (ctxt->cache)) {
2384 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2408 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
2426 ctxt->lastError.domain = XML_FROM_XPATH;
2427 ctxt->lastError.code = XML_ERR_NO_MEMORY;
2431 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
2441 * @ctxt: the XPath context
2450 xmlXPathCacheNewCString(xmlXPathContextPtr ctxt, const char *val)
2452 if ((ctxt != NULL) && (ctxt->cache)) {
2453 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2466 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2480 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2490 * @ctxt: the XPath context
2499 xmlXPathCacheNewString(xmlXPathContextPtr ctxt, const xmlChar *val)
2501 if ((ctxt != NULL) && (ctxt->cache)) {
2502 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2517 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2534 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2544 * @ctxt: the XPath context
2553 xmlXPathCacheNewBoolean(xmlXPathContextPtr ctxt, int val)
2555 if ((ctxt != NULL) && (ctxt->cache)) {
2556 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2568 xmlXPathDebugObjUsageRequested(ctxt, XPATH_BOOLEAN);
2582 xmlXPathDebugObjUsageRequested(ctxt, XPATH_BOOLEAN);
2592 * @ctxt: the XPath context
2601 xmlXPathCacheNewFloat(xmlXPathContextPtr ctxt, double val)
2603 if ((ctxt != NULL) && (ctxt->cache)) {
2604 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2616 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NUMBER);
2630 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NUMBER);
2640 * @ctxt: the XPath context
2651 xmlXPathCacheConvertString(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
2655 return(xmlXPathCacheNewCString(ctxt, ""));
2682 xmlXPathReleaseObject(ctxt, val);
2684 return(xmlXPathCacheNewCString(ctxt, ""));
2685 return(xmlXPathCacheWrapString(ctxt, res));
2690 * @ctxt: the XPath context
2699 xmlXPathCacheObjectCopy(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val)
2704 if (XP_HAS_CACHE(ctxt)) {
2707 return(xmlXPathCacheWrapNodeSet(ctxt,
2710 return(xmlXPathCacheNewString(ctxt, val->stringval));
2712 return(xmlXPathCacheNewBoolean(ctxt, val->boolval));
2714 return(xmlXPathCacheNewFloat(ctxt, val->floatval));
2724 * @ctxt: the XPath context
2734 xmlXPathCacheConvertBoolean(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
2738 return(xmlXPathCacheNewBoolean(ctxt, 0));
2741 ret = xmlXPathCacheNewBoolean(ctxt, xmlXPathCastToBoolean(val));
2742 xmlXPathReleaseObject(ctxt, val);
2748 * @ctxt: the XPath context
2758 xmlXPathCacheConvertNumber(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
2762 return(xmlXPathCacheNewFloat(ctxt, 0.0));
2765 ret = xmlXPathCacheNewFloat(ctxt, xmlXPathCastToNumber(val));
2766 xmlXPathReleaseObject(ctxt, val);
2778 * @ctxt: an XPath parser context
2785 xmlXPathSetFrame(xmlXPathParserContextPtr ctxt) {
2788 if (ctxt == NULL)
2790 ret = ctxt->valueFrame;
2791 ctxt->valueFrame = ctxt->valueNr;
2797 * @ctxt: an XPath parser context
2803 xmlXPathPopFrame(xmlXPathParserContextPtr ctxt, int frame) {
2804 if (ctxt == NULL)
2806 if (ctxt->valueNr < ctxt->valueFrame) {
2807 xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_STACK_ERROR);
2809 ctxt->valueFrame = frame;
2814 * @ctxt: an XPath evaluation context
2821 valuePop(xmlXPathParserContextPtr ctxt)
2825 if ((ctxt == NULL) || (ctxt->valueNr <= 0))
2828 if (ctxt->valueNr <= ctxt->valueFrame) {
2829 xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_STACK_ERROR);
2833 ctxt->valueNr--;
2834 if (ctxt->valueNr > 0)
2835 ctxt->value = ctxt->valueTab[ctxt->valueNr - 1];
2837 ctxt->value = NULL;
2838 ret = ctxt->valueTab[ctxt->valueNr];
2839 ctxt->valueTab[ctxt->valueNr] = NULL;
2844 * @ctxt: an XPath evaluation context
2852 valuePush(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value)
2854 if ((ctxt == NULL) || (value == NULL)) return(-1);
2855 if (ctxt->valueNr >= ctxt->valueMax) {
2858 if (ctxt->valueMax >= XPATH_MAX_STACK_DEPTH) {
2860 ctxt->error = XPATH_MEMORY_ERROR;
2863 tmp = (xmlXPathObjectPtr *) xmlRealloc(ctxt->valueTab,
2864 2 * ctxt->valueMax *
2865 sizeof(ctxt->valueTab[0]));
2868 ctxt->error = XPATH_MEMORY_ERROR;
2871 ctxt->valueMax *= 2;
2872 ctxt->valueTab = tmp;
2874 ctxt->valueTab[ctxt->valueNr] = value;
2875 ctxt->value = value;
2876 return (ctxt->valueNr++);
2881 * @ctxt: an XPath parser context
2889 xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt) {
2893 obj = valuePop(ctxt);
2895 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
2902 xmlXPathReleaseObject(ctxt->context, obj);
2908 * @ctxt: an XPath parser context
2916 xmlXPathPopNumber (xmlXPathParserContextPtr ctxt) {
2920 obj = valuePop(ctxt);
2922 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
2929 xmlXPathReleaseObject(ctxt->context, obj);
2935 * @ctxt: an XPath parser context
2943 xmlXPathPopString (xmlXPathParserContextPtr ctxt) {
2947 obj = valuePop(ctxt);
2949 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
2956 xmlXPathReleaseObject(ctxt->context, obj);
2962 * @ctxt: an XPath parser context
2970 xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt) {
2974 if (ctxt == NULL) return(NULL);
2975 if (ctxt->value == NULL) {
2976 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
2979 if (!xmlXPathStackIsNodeSet(ctxt)) {
2980 xmlXPathSetTypeError(ctxt);
2983 obj = valuePop(ctxt);
2991 xmlXPathReleaseObject(ctxt->context, obj);
2997 * @ctxt: an XPath parser context
3005 xmlXPathPopExternal (xmlXPathParserContextPtr ctxt) {
3009 if ((ctxt == NULL) || (ctxt->value == NULL)) {
3010 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
3013 if (ctxt->value->type != XPATH_USERS) {
3014 xmlXPathSetTypeError(ctxt);
3017 obj = valuePop(ctxt);
3020 xmlXPathReleaseObject(ctxt->context, obj);
3047 #define CUR (*ctxt->cur)
3048 #define SKIP(val) ctxt->cur += (val)
3049 #define NXT(val) ctxt->cur[(val)]
3050 #define CUR_PTR ctxt->cur
3051 #define CUR_CHAR(l) xmlXPathCurrentChar(ctxt, &l)
3057 #define NEXTL(l) ctxt->cur += l
3060 while (IS_BLANK_CH(*(ctxt->cur))) NEXT
3062 #define CURRENT (*ctxt->cur)
3063 #define NEXT ((*ctxt->cur) ? ctxt->cur++: ctxt->cur)
4844 * @ctxt: the XPath context
4853 xmlXPathRegisterFunc(xmlXPathContextPtr ctxt, const xmlChar *name,
4855 return(xmlXPathRegisterFuncNS(ctxt, name, NULL, f));
4860 * @ctxt: the XPath context
4870 xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name,
4872 if (ctxt == NULL)
4877 if (ctxt->funcHash == NULL)
4878 ctxt->funcHash = xmlHashCreate(0);
4879 if (ctxt->funcHash == NULL)
4882 return(xmlHashRemoveEntry2(ctxt->funcHash, name, ns_uri, NULL));
4884 return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, (void *) f));
4890 * @ctxt: the XPath context
4897 xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
4900 if (ctxt == NULL)
4902 ctxt->funcLookupFunc = f;
4903 ctxt->funcLookupData = funcCtxt;
4908 * @ctxt: the XPath context
4917 xmlXPathFunctionLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
4918 if (ctxt == NULL)
4921 if (ctxt->funcLookupFunc != NULL) {
4925 f = ctxt->funcLookupFunc;
4926 ret = f(ctxt->funcLookupData, name, NULL);
4930 return(xmlXPathFunctionLookupNS(ctxt, name, NULL));
4935 * @ctxt: the XPath context
4945 xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
4949 if (ctxt == NULL)
4954 if (ctxt->funcLookupFunc != NULL) {
4957 f = ctxt->funcLookupFunc;
4958 ret = f(ctxt->funcLookupData, name, ns_uri);
4963 if (ctxt->funcHash == NULL)
4967 ret = (xmlXPathFunction) xmlHashLookup2(ctxt->funcHash, name, ns_uri);
4974 * @ctxt: the XPath context
4979 xmlXPathRegisteredFuncsCleanup(xmlXPathContextPtr ctxt) {
4980 if (ctxt == NULL)
4983 xmlHashFree(ctxt->funcHash, NULL);
4984 ctxt->funcHash = NULL;
4995 * @ctxt: the XPath context
5005 xmlXPathRegisterVariable(xmlXPathContextPtr ctxt, const xmlChar *name,
5007 return(xmlXPathRegisterVariableNS(ctxt, name, NULL, value));
5012 * @ctxt: the XPath context
5023 xmlXPathRegisterVariableNS(xmlXPathContextPtr ctxt, const xmlChar *name,
5026 if (ctxt == NULL)
5031 if (ctxt->varHash == NULL)
5032 ctxt->varHash = xmlHashCreate(0);
5033 if (ctxt->varHash == NULL)
5036 return(xmlHashRemoveEntry2(ctxt->varHash, name, ns_uri,
5038 return(xmlHashUpdateEntry2(ctxt->varHash, name, ns_uri,
5044 * @ctxt: the XPath context
5051 xmlXPathRegisterVariableLookup(xmlXPathContextPtr ctxt,
5053 if (ctxt == NULL)
5055 ctxt->varLookupFunc = f;
5056 ctxt->varLookupData = data;
5061 * @ctxt: the XPath context
5070 xmlXPathVariableLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
5071 if (ctxt == NULL)
5074 if (ctxt->varLookupFunc != NULL) {
5077 ret = ((xmlXPathVariableLookupFunc)ctxt->varLookupFunc)
5078 (ctxt->varLookupData, name, NULL);
5081 return(xmlXPathVariableLookupNS(ctxt, name, NULL));
5086 * @ctxt: the XPath context
5096 xmlXPathVariableLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
5098 if (ctxt == NULL)
5101 if (ctxt->varLookupFunc != NULL) {
5104 ret = ((xmlXPathVariableLookupFunc)ctxt->varLookupFunc)
5105 (ctxt->varLookupData, name, ns_uri);
5109 if (ctxt->varHash == NULL)
5114 return(xmlXPathCacheObjectCopy(ctxt, (xmlXPathObjectPtr)
5115 xmlHashLookup2(ctxt->varHash, name, ns_uri)));
5120 * @ctxt: the XPath context
5125 xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt) {
5126 if (ctxt == NULL)
5129 xmlHashFree(ctxt->varHash, xmlXPathFreeObjectEntry);
5130 ctxt->varHash = NULL;
5135 * @ctxt: the XPath context
5145 xmlXPathRegisterNs(xmlXPathContextPtr ctxt, const xmlChar *prefix,
5147 if (ctxt == NULL)
5154 if (ctxt->nsHash == NULL)
5155 ctxt->nsHash = xmlHashCreate(10);
5156 if (ctxt->nsHash == NULL)
5159 return(xmlHashRemoveEntry(ctxt->nsHash, prefix,
5161 return(xmlHashUpdateEntry(ctxt->nsHash, prefix, (void *) xmlStrdup(ns_uri),
5167 * @ctxt: the XPath context
5176 xmlXPathNsLookup(xmlXPathContextPtr ctxt, const xmlChar *prefix) {
5177 if (ctxt == NULL)
5187 if (ctxt->namespaces != NULL) {
5190 for (i = 0;i < ctxt->nsNr;i++) {
5191 if ((ctxt->namespaces[i] != NULL) &&
5192 (xmlStrEqual(ctxt->namespaces[i]->prefix, prefix)))
5193 return(ctxt->namespaces[i]->href);
5197 return((const xmlChar *) xmlHashLookup(ctxt->nsHash, prefix));
5202 * @ctxt: the XPath context
5207 xmlXPathRegisteredNsCleanup(xmlXPathContextPtr ctxt) {
5208 if (ctxt == NULL)
5211 xmlHashFree(ctxt->nsHash, xmlHashDefaultDeallocator);
5212 ctxt->nsHash = NULL;
5538 xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj)
5548 if ((ctxt == NULL) || (ctxt->cache == NULL)) {
5552 (xmlXPathContextCachePtr) ctxt->cache;
5622 xmlXPathDebugObjUsageReleased(ctxt, obj->type);
6172 * @ctxt: the context to free
6177 xmlXPathFreeContext(xmlXPathContextPtr ctxt) {
6178 if (ctxt == NULL) return;
6180 if (ctxt->cache != NULL)
6181 xmlXPathFreeCache((xmlXPathContextCachePtr) ctxt->cache);
6182 xmlXPathRegisteredNsCleanup(ctxt);
6183 xmlXPathRegisteredFuncsCleanup(ctxt);
6184 xmlXPathRegisteredVariablesCleanup(ctxt);
6185 xmlResetError(&ctxt->lastError);
6186 xmlFree(ctxt);
6195 #define CHECK_CTXT(ctxt) \
6196 if (ctxt == NULL) { \
6206 #define CHECK_CTXT_NEG(ctxt) \
6207 if (ctxt == NULL) { \
6218 #define CHECK_CONTEXT(ctxt) \
6219 if ((ctxt == NULL) || (ctxt->doc == NULL) || \
6220 (ctxt->doc->children == NULL)) { \
6221 xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_INVALID_CTXT); \
6229 * @ctxt: the XPath context
6236 xmlXPathNewParserContext(const xmlChar *str, xmlXPathContextPtr ctxt) {
6241 xmlXPathErrMemory(ctxt, "creating parser context\n");
6246 ret->context = ctxt;
6254 if ((ctxt != NULL) && (ctxt->dict != NULL)) {
6255 ret->comp->dict = ctxt->dict;
6265 * @ctxt: the XPath context
6272 xmlXPathCompParserContext(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt) {
6277 xmlXPathErrMemory(ctxt, "creating evaluation context\n");
6287 xmlXPathErrMemory(ctxt, "creating evaluation context\n");
6295 ret->context = ctxt;
6303 * @ctxt: the context to free
6308 xmlXPathFreeParserContext(xmlXPathParserContextPtr ctxt) {
6311 if (ctxt->valueTab != NULL) {
6312 for (i = 0; i < ctxt->valueNr; i++) {
6313 if (ctxt->context)
6314 xmlXPathReleaseObject(ctxt->context, ctxt->valueTab[i]);
6316 xmlXPathFreeObject(ctxt->valueTab[i]);
6318 xmlFree(ctxt->valueTab);
6320 if (ctxt->comp != NULL) {
6322 if (ctxt->comp->stream != NULL) {
6323 xmlFreePatternList(ctxt->comp->stream);
6324 ctxt->comp->stream = NULL;
6327 xmlXPathFreeCompExpr(ctxt->comp);
6329 xmlFree(ctxt);
6474 * @ctxt: the XPath Parser context
6495 xmlXPathCompareNodeSetFloat(xmlXPathParserContextPtr ctxt, int inf, int strict,
6503 xmlXPathReleaseObject(ctxt->context, arg);
6504 xmlXPathReleaseObject(ctxt->context, f);
6512 valuePush(ctxt,
6513 xmlXPathCacheNewString(ctxt->context, str2));
6515 xmlXPathNumberFunction(ctxt, 1);
6516 valuePush(ctxt, xmlXPathCacheObjectCopy(ctxt->context, f));
6517 ret = xmlXPathCompareValues(ctxt, inf, strict);
6523 xmlXPathReleaseObject(ctxt->context, arg);
6524 xmlXPathReleaseObject(ctxt->context, f);
6530 * @ctxt: the XPath Parser context
6550 xmlXPathCompareNodeSetString(xmlXPathParserContextPtr ctxt, int inf, int strict,
6558 xmlXPathReleaseObject(ctxt->context, arg);
6559 xmlXPathReleaseObject(ctxt->context, s);
6567 valuePush(ctxt,
6568 xmlXPathCacheNewString(ctxt->context, str2));
6570 valuePush(ctxt, xmlXPathCacheObjectCopy(ctxt->context, s));
6571 ret = xmlXPathCompareValues(ctxt, inf, strict);
6577 xmlXPathReleaseObject(ctxt->context, arg);
6578 xmlXPathReleaseObject(ctxt->context, s);
6686 * @ctxt: the XPath Parser context
6706 xmlXPathCompareNodeSetValue(xmlXPathParserContextPtr ctxt, int inf, int strict,
6714 return(xmlXPathCompareNodeSetFloat(ctxt, inf, strict, arg, val));
6719 return(xmlXPathCompareNodeSetString(ctxt, inf, strict, arg, val));
6721 valuePush(ctxt, arg);
6722 xmlXPathBooleanFunction(ctxt, 1);
6723 valuePush(ctxt, val);
6724 return(xmlXPathCompareValues(ctxt, inf, strict));
6730 xmlXPathReleaseObject(ctxt->context, arg);
6731 xmlXPathReleaseObject(ctxt->context, val);
6811 xmlXPathEqualNodeSetFloat(xmlXPathParserContextPtr ctxt,
6828 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, str2));
6830 xmlXPathNumberFunction(ctxt, 1);
6831 val = valuePop(ctxt);
6833 xmlXPathReleaseObject(ctxt->context, val);
6972 xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
7037 valuePush(ctxt, arg2);
7038 xmlXPathNumberFunction(ctxt, 1);
7039 arg2 = valuePop(ctxt);
7100 valuePush(ctxt, arg1);
7101 xmlXPathNumberFunction(ctxt, 1);
7102 arg1 = valuePop(ctxt);
7152 xmlXPathReleaseObject(ctxt->context, arg1);
7153 xmlXPathReleaseObject(ctxt->context, arg2);
7159 * @ctxt: the XPath Parser context
7166 xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
7170 if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
7171 arg2 = valuePop(ctxt);
7172 arg1 = valuePop(ctxt);
7175 xmlXPathReleaseObject(ctxt->context, arg1);
7177 xmlXPathReleaseObject(ctxt->context, arg2);
7222 ret = xmlXPathEqualNodeSetFloat(ctxt, arg1, arg2->floatval, 0);
7234 xmlXPathReleaseObject(ctxt->context, arg1);
7235 xmlXPathReleaseObject(ctxt->context, arg2);
7239 return (xmlXPathEqualValuesCommon(ctxt, arg1, arg2));
7244 * @ctxt: the XPath Parser context
7251 xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt) {
7255 if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
7256 arg2 = valuePop(ctxt);
7257 arg1 = valuePop(ctxt);
7260 xmlXPathReleaseObject(ctxt->context, arg1);
7262 xmlXPathReleaseObject(ctxt->context, arg2);
7271 xmlXPathReleaseObject(ctxt->context, arg1);
7307 ret = xmlXPathEqualNodeSetFloat(ctxt, arg1, arg2->floatval, 1);
7319 xmlXPathReleaseObject(ctxt->context, arg1);
7320 xmlXPathReleaseObject(ctxt->context, arg2);
7324 return (!xmlXPathEqualValuesCommon(ctxt, arg1, arg2));
7329 * @ctxt: the XPath Parser context
7352 xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict) {
7356 if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
7357 arg2 = valuePop(ctxt);
7358 arg1 = valuePop(ctxt);
7361 xmlXPathReleaseObject(ctxt->context, arg1);
7363 xmlXPathReleaseObject(ctxt->context, arg2);
7379 ret = xmlXPathCompareNodeSetValue(ctxt, inf, strict,
7382 ret = xmlXPathCompareNodeSetValue(ctxt, !inf, strict,
7390 valuePush(ctxt, arg1);
7391 xmlXPathNumberFunction(ctxt, 1);
7392 arg1 = valuePop(ctxt);
7400 valuePush(ctxt, arg2);
7401 xmlXPathNumberFunction(ctxt, 1);
7402 arg2 = valuePop(ctxt);
7405 xmlXPathReleaseObject(ctxt->context, arg1);
7406 xmlXPathReleaseObject(ctxt->context, arg2);
7458 xmlXPathReleaseObject(ctxt->context, arg1);
7459 xmlXPathReleaseObject(ctxt->context, arg2);
7465 * @ctxt: the XPath Parser context
7472 xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt) {
7473 if ((ctxt == NULL) || (ctxt->context == NULL)) return;
7476 ctxt->value->floatval = -ctxt->value->floatval;
7481 * @ctxt: the XPath Parser context
7488 xmlXPathAddValues(xmlXPathParserContextPtr ctxt) {
7492 arg = valuePop(ctxt);
7496 xmlXPathReleaseObject(ctxt->context, arg);
7499 ctxt->value->floatval += val;
7504 * @ctxt: the XPath Parser context
7511 xmlXPathSubValues(xmlXPathParserContextPtr ctxt) {
7515 arg = valuePop(ctxt);
7519 xmlXPathReleaseObject(ctxt->context, arg);
7522 ctxt->value->floatval -= val;
7527 * @ctxt: the XPath Parser context
7534 xmlXPathMultValues(xmlXPathParserContextPtr ctxt) {
7538 arg = valuePop(ctxt);
7542 xmlXPathReleaseObject(ctxt->context, arg);
7545 ctxt->value->floatval *= val;
7550 ctxt: the XPath Parser context
7557 xmlXPathDivValues(xmlXPathParserContextPtr ctxt) {
7561 arg = valuePop(ctxt);
7565 xmlXPathReleaseObject(ctxt->context, arg);
7568 ctxt->value->floatval /= val;
7573 * @ctxt: the XPath Parser context
7580 xmlXPathModValues(xmlXPathParserContextPtr ctxt) {
7584 arg = valuePop(ctxt);
7588 xmlXPathReleaseObject(ctxt->context, arg);
7591 arg1 = ctxt->value->floatval;
7593 ctxt->value->floatval = NAN;
7595 ctxt->value->floatval = fmod(arg1, arg2);
7611 (xmlXPathParserContextPtr ctxt, xmlNodePtr cur);
7633 * @ctxt: the XPath Parser context
7642 xmlXPathNextSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7643 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7645 return(ctxt->context->node);
7651 * @ctxt: the XPath Parser context
7660 xmlXPathNextChild(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7661 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7663 if (ctxt->context->node == NULL) return(NULL);
7664 switch (ctxt->context->node->type) {
7674 return(ctxt->context->node->children);
7682 return(((xmlDocPtr) ctxt->context->node)->children);
7702 * @ctxt: the XPath Parser context
7711 xmlXPathNextChildElement(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7712 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7714 cur = ctxt->context->node;
7778 * @ctxt: the XPath Parser context
7855 * @ctxt: the XPath Parser context
7865 xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7866 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7868 if (ctxt->context->node == NULL)
7870 if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
7871 (ctxt->context->node->type == XML_NAMESPACE_DECL))
7874 if (ctxt->context->node == (xmlNodePtr) ctxt->context->doc)
7875 return(ctxt->context->doc->children);
7876 return(ctxt->context->node->children);
7895 if (cur == ctxt->context->node) return(NULL);
7907 if (cur == ctxt->context->node) return(NULL);
7918 * @ctxt: the XPath Parser context
7930 xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7931 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7933 return(ctxt->context->node);
7935 if (ctxt->context->node == NULL)
7937 if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
7938 (ctxt->context->node->type == XML_NAMESPACE_DECL))
7941 return(xmlXPathNextDescendant(ctxt, cur));
7946 * @ctxt: the XPath Parser context
7955 xmlXPathNextParent(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7956 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7963 if (ctxt->context->node == NULL) return(NULL);
7964 switch (ctxt->context->node->type) {
7979 if (ctxt->context->node->parent == NULL)
7980 return((xmlNodePtr) ctxt->context->doc);
7981 if ((ctxt->context->node->parent->type == XML_ELEMENT_NODE) &&
7982 ((ctxt->context->node->parent->name[0] == ' ') ||
7983 (xmlStrEqual(ctxt->context->node->parent->name,
7986 return(ctxt->context->node->parent);
7988 xmlAttrPtr att = (xmlAttrPtr) ctxt->context->node;
8001 xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
8015 * @ctxt: the XPath Parser context
8028 xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8029 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8036 if (ctxt->context->node == NULL) return(NULL);
8037 switch (ctxt->context->node->type) {
8052 if (ctxt->context->node->parent == NULL)
8053 return((xmlNodePtr) ctxt->context->doc);
8054 if ((ctxt->context->node->parent->type == XML_ELEMENT_NODE) &&
8055 ((ctxt->context->node->parent->name[0] == ' ') ||
8056 (xmlStrEqual(ctxt->context->node->parent->name,
8059 return(ctxt->context->node->parent);
8061 xmlAttrPtr tmp = (xmlAttrPtr) ctxt->context->node;
8074 xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
8085 if (cur == ctxt->context->doc->children)
8086 return((xmlNodePtr) ctxt->context->doc);
8087 if (cur == (xmlNodePtr) ctxt->context->doc)
8140 * @ctxt: the XPath Parser context
8152 xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8153 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8155 return(ctxt->context->node);
8156 return(xmlXPathNextAncestor(ctxt, cur));
8161 * @ctxt: the XPath Parser context
8171 xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8172 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8173 if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
8174 (ctxt->context->node->type == XML_NAMESPACE_DECL))
8176 if (cur == (xmlNodePtr) ctxt->context->doc)
8179 return(ctxt->context->node->next);
8185 * @ctxt: the XPath Parser context
8196 xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8197 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8198 if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
8199 (ctxt->context->node->type == XML_NAMESPACE_DECL))
8201 if (cur == (xmlNodePtr) ctxt->context->doc)
8204 return(ctxt->context->node->prev);
8208 return(ctxt->context->node->prev);
8215 * @ctxt: the XPath Parser context
8227 xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8228 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8234 cur = ctxt->context->node;
8251 if (cur == (xmlNodePtr) ctxt->context->doc) return(NULL);
8288 * @ctxt: the XPath Parser context
8300 xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur)
8302 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8304 cur = ctxt->context->node;
8329 if (cur == ctxt->context->doc->children)
8331 } while (xmlXPathIsAncestor(cur, ctxt->context->node));
8337 * @ctxt: the XPath Parser context
8346 * state kept in the parser context: ctxt->ancestor.
8351 xmlXPathNextPrecedingInternal(xmlXPathParserContextPtr ctxt,
8354 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8356 cur = ctxt->context->node;
8369 ctxt->ancestor = cur->parent;
8379 if (cur == ctxt->context->doc->children)
8381 if (cur != ctxt->ancestor)
8383 ctxt->ancestor = cur->parent;
8393 * @ctxt: the XPath Parser context
8406 xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8407 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8408 if (ctxt->context->node->type != XML_ELEMENT_NODE) return(NULL);
8410 if (ctxt->context->tmpNsList != NULL)
8411 xmlFree(ctxt->context->tmpNsList);
8412 ctxt->context->tmpNsList =
8413 xmlGetNsList(ctxt->context->doc, ctxt->context->node);
8414 ctxt->context->tmpNsNr = 0;
8415 if (ctxt->context->tmpNsList != NULL) {
8416 while (ctxt->context->tmpNsList[ctxt->context->tmpNsNr] != NULL) {
8417 ctxt->context->tmpNsNr++;
8422 if (ctxt->context->tmpNsNr > 0) {
8423 return (xmlNodePtr)ctxt->context->tmpNsList[--ctxt->context->tmpNsNr];
8425 if (ctxt->context->tmpNsList != NULL)
8426 xmlFree(ctxt->context->tmpNsList);
8427 ctxt->context->tmpNsList = NULL;
8434 * @ctxt: the XPath Parser context
8443 xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8444 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8445 if (ctxt->context->node == NULL)
8447 if (ctxt->context->node->type != XML_ELEMENT_NODE)
8450 if (ctxt->context->node == (xmlNodePtr) ctxt->context->doc)
8452 return((xmlNodePtr)ctxt->context->node->properties);
8474 * @ctxt: the XPath Parser context
8479 xmlXPathRoot(xmlXPathParserContextPtr ctxt) {
8480 if ((ctxt == NULL) || (ctxt->context == NULL))
8482 ctxt->context->node = (xmlNodePtr) ctxt->context->doc;
8483 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8484 ctxt->context->node));
8497 * @ctxt: the XPath Parser context
8505 xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8507 if (ctxt->context->contextSize >= 0) {
8508 valuePush(ctxt,
8509 xmlXPathCacheNewFloat(ctxt->context,
8510 (double) ctxt->context->contextSize));
8513 "last() : %d\n", ctxt->context->contextSize);
8522 * @ctxt: the XPath Parser context
8532 xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8534 if (ctxt->context->proximityPosition >= 0) {
8535 valuePush(ctxt,
8536 xmlXPathCacheNewFloat(ctxt->context,
8537 (double) ctxt->context->proximityPosition));
8540 ctxt->context->proximityPosition);
8549 * @ctxt: the XPath Parser context
8556 xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8560 if ((ctxt->value == NULL) ||
8561 ((ctxt->value->type != XPATH_NODESET) &&
8562 (ctxt->value->type != XPATH_XSLT_TREE)))
8564 cur = valuePop(ctxt);
8567 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0));
8569 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context,
8574 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0));
8587 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) i));
8590 xmlXPathReleaseObject(ctxt->context, cur);
8652 * @ctxt: the XPath Parser context
8669 xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8675 obj = valuePop(ctxt);
8685 * ctxt, so the object is in a corrupt state.
8692 ns = xmlXPathGetElementsByIds(ctxt->context->doc, tokens);
8699 xmlXPathReleaseObject(ctxt->context, obj);
8700 valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, ret));
8703 obj = xmlXPathCacheConvertString(ctxt->context, obj);
8704 ret = xmlXPathGetElementsByIds(ctxt->context->doc, obj->stringval);
8705 valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, ret));
8706 xmlXPathReleaseObject(ctxt->context, obj);
8712 * @ctxt: the XPath Parser context
8724 xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8727 if (ctxt == NULL) return;
8730 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8731 ctxt->context->node));
8736 if ((ctxt->value == NULL) ||
8737 ((ctxt->value->type != XPATH_NODESET) &&
8738 (ctxt->value->type != XPATH_XSLT_TREE)))
8740 cur = valuePop(ctxt);
8743 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8751 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8753 valuePush(ctxt,
8754 xmlXPathCacheNewString(ctxt->context,
8758 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
8762 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8765 xmlXPathReleaseObject(ctxt->context, cur);
8770 * @ctxt: the XPath Parser context
8783 xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8786 if (ctxt == NULL) return;
8789 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8790 ctxt->context->node));
8794 if ((ctxt->value == NULL) ||
8795 ((ctxt->value->type != XPATH_NODESET) &&
8796 (ctxt->value->type != XPATH_XSLT_TREE)))
8798 cur = valuePop(ctxt);
8801 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8808 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8810 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
8814 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8817 xmlXPathReleaseObject(ctxt->context, cur);
8822 * @ctxt: the XPath Parser context
8843 xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs)
8848 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8849 ctxt->context->node));
8854 if ((ctxt->value == NULL) ||
8855 ((ctxt->value->type != XPATH_NODESET) &&
8856 (ctxt->value->type != XPATH_XSLT_TREE)))
8858 cur = valuePop(ctxt);
8861 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8869 valuePush(ctxt,
8870 xmlXPathCacheNewCString(ctxt->context, ""));
8873 valuePush(ctxt,
8874 xmlXPathCacheNewString(ctxt->context,
8887 valuePush(ctxt, xmlXPathCacheWrapString(
8888 ctxt->context, fullname));
8892 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8894 xmlXPathLocalNameFunction(ctxt, 1);
8897 xmlXPathReleaseObject(ctxt->context, cur);
8903 * @ctxt: the XPath Parser context
8938 xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8941 if (ctxt == NULL) return;
8943 valuePush(ctxt,
8944 xmlXPathCacheWrapString(ctxt->context,
8945 xmlXPathCastNodeToString(ctxt->context->node)));
8950 cur = valuePop(ctxt);
8952 valuePush(ctxt, xmlXPathCacheConvertString(ctxt->context, cur));
8957 * @ctxt: the XPath Parser context
8968 xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8972 if ((ctxt == NULL) || (ctxt->context == NULL))
8974 if (ctxt->context->node == NULL) {
8975 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, 0));
8979 content = xmlXPathCastNodeToString(ctxt->context->node);
8980 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context,
8989 cur = valuePop(ctxt);
8990 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context,
8992 xmlXPathReleaseObject(ctxt->context, cur);
8997 * @ctxt: the XPath Parser context
9005 xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9009 if (ctxt == NULL) return;
9015 cur = valuePop(ctxt);
9017 xmlXPathReleaseObject(ctxt->context, cur);
9024 newobj = valuePop(ctxt);
9026 xmlXPathReleaseObject(ctxt->context, newobj);
9027 xmlXPathReleaseObject(ctxt->context, cur);
9033 xmlXPathReleaseObject(ctxt->context, newobj);
9036 valuePush(ctxt, cur);
9041 * @ctxt: the XPath Parser context
9050 xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9056 needle = valuePop(ctxt);
9058 hay = valuePop(ctxt);
9061 xmlXPathReleaseObject(ctxt->context, hay);
9062 xmlXPathReleaseObject(ctxt->context, needle);
9066 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 1));
9068 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 0));
9069 xmlXPathReleaseObject(ctxt->context, hay);
9070 xmlXPathReleaseObject(ctxt->context, needle);
9075 * @ctxt: the XPath Parser context
9084 xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9091 needle = valuePop(ctxt);
9093 hay = valuePop(ctxt);
9096 xmlXPathReleaseObject(ctxt->context, hay);
9097 xmlXPathReleaseObject(ctxt->context, needle);
9102 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 0));
9104 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 1));
9105 xmlXPathReleaseObject(ctxt->context, hay);
9106 xmlXPathReleaseObject(ctxt->context, needle);
9111 * @ctxt: the XPath Parser context
9138 xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9156 len = valuePop(ctxt);
9158 xmlXPathReleaseObject(ctxt->context, len);
9163 start = valuePop(ctxt);
9165 xmlXPathReleaseObject(ctxt->context, start);
9168 str = valuePop(ctxt);
9225 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
9227 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, ret));
9230 xmlXPathReleaseObject(ctxt->context, str);
9235 * @ctxt: the XPath Parser context
9247 xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9256 find = valuePop(ctxt);
9258 str = valuePop(ctxt);
9267 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
9271 xmlXPathReleaseObject(ctxt->context, str);
9272 xmlXPathReleaseObject(ctxt->context, find);
9277 * @ctxt: the XPath Parser context
9290 xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9299 find = valuePop(ctxt);
9301 str = valuePop(ctxt);
9311 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
9315 xmlXPathReleaseObject(ctxt->context, str);
9316 xmlXPathReleaseObject(ctxt->context, find);
9321 * @ctxt: the XPath Parser context
9334 xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9340 if (ctxt == NULL) return;
9343 valuePush(ctxt,
9344 xmlXPathCacheWrapString(ctxt->context,
9345 xmlXPathCastNodeToString(ctxt->context->node)));
9352 obj = valuePop(ctxt);
9376 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
9380 xmlXPathReleaseObject(ctxt->context, obj);
9385 * @ctxt: the XPath Parser context
9405 xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9418 to = valuePop(ctxt);
9420 from = valuePop(ctxt);
9422 str = valuePop(ctxt);
9461 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
9464 xmlXPathReleaseObject(ctxt->context, str);
9465 xmlXPathReleaseObject(ctxt->context, from);
9466 xmlXPathReleaseObject(ctxt->context, to);
9471 * @ctxt: the XPath Parser context
9483 xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9487 cur = valuePop(ctxt);
9489 cur = xmlXPathCacheConvertBoolean(ctxt->context, cur);
9490 valuePush(ctxt, cur);
9495 * @ctxt: the XPath Parser context
9504 xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9508 ctxt->value->boolval = ! ctxt->value->boolval;
9513 * @ctxt: the XPath Parser context
9520 xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9522 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 1));
9527 * @ctxt: the XPath Parser context
9534 xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9536 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 0));
9541 * @ctxt: the XPath Parser context
9561 xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9571 val = valuePop(ctxt);
9573 theLang = xmlNodeGetLang(ctxt->context->node);
9585 xmlXPathReleaseObject(ctxt->context, val);
9586 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, ret));
9591 * @ctxt: the XPath Parser context
9598 xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9602 if (ctxt == NULL) return;
9604 if (ctxt->context->node == NULL) {
9605 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, 0.0));
9607 xmlChar* content = xmlNodeGetContent(ctxt->context->node);
9610 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, res));
9617 cur = valuePop(ctxt);
9618 valuePush(ctxt, xmlXPathCacheConvertNumber(ctxt->context, cur));
9623 * @ctxt: the XPath Parser context
9632 xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9638 if ((ctxt->value == NULL) ||
9639 ((ctxt->value->type != XPATH_NODESET) &&
9640 (ctxt->value->type != XPATH_XSLT_TREE)))
9642 cur = valuePop(ctxt);
9649 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, res));
9650 xmlXPathReleaseObject(ctxt->context, cur);
9655 * @ctxt: the XPath Parser context
9664 xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9669 ctxt->value->floatval = floor(ctxt->value->floatval);
9674 * @ctxt: the XPath Parser context
9683 xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9688 ctxt->value->floatval = ceil(ctxt->value->floatval);
9693 * @ctxt: the XPath Parser context
9703 xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9710 f = ctxt->value->floatval;
9714 ctxt->value->floatval *= 0.0;
9720 ctxt->value->floatval = rounded;
9734 static void xmlXPathCompileExpr(xmlXPathParserContextPtr ctxt, int sort);
9735 static void xmlXPathCompPredicate(xmlXPathParserContextPtr ctxt, int filter);
9736 static void xmlXPathCompLocationPath(xmlXPathParserContextPtr ctxt);
9737 static void xmlXPathCompRelativeLocationPath(xmlXPathParserContextPtr ctxt);
9738 static xmlChar * xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt,
9743 * @ctxt: the XPath parser context
9754 xmlXPathCurrentChar(xmlXPathParserContextPtr ctxt, int *len) {
9759 if (ctxt == NULL)
9761 cur = ctxt->cur;
9828 * @ctxt: the XPath Parser context
9841 xmlXPathParseNCName(xmlXPathParserContextPtr ctxt) {
9846 if ((ctxt == NULL) || (ctxt->cur == NULL)) return(NULL);
9850 in = ctxt->cur;
9864 count = in - ctxt->cur;
9867 ret = xmlStrndup(ctxt->cur, count);
9868 ctxt->cur = in;
9872 return(xmlXPathParseNameComplex(ctxt, 0));
9878 * @ctxt: the XPath Parser context
9894 xmlXPathParseQName(xmlXPathParserContextPtr ctxt, xmlChar **prefix) {
9898 ret = xmlXPathParseNCName(ctxt);
9902 ret = xmlXPathParseNCName(ctxt);
9909 * @ctxt: the XPath Parser context
9922 xmlXPathParseName(xmlXPathParserContextPtr ctxt) {
9927 if ((ctxt == NULL) || (ctxt->cur == NULL)) return(NULL);
9931 in = ctxt->cur;
9943 count = in - ctxt->cur;
9945 ctxt->cur = in;
9948 ret = xmlStrndup(ctxt->cur, count);
9949 ctxt->cur = in;
9953 return(xmlXPathParseNameComplex(ctxt, 1));
9957 xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {
10139 * @ctxt: the XPath Parser context
10149 xmlXPathCompNumber(xmlXPathParserContextPtr ctxt)
10228 xmlXPathCacheNewFloat(ctxt->context, ret), NULL);
10233 * @ctxt: the XPath Parser context
10243 xmlXPathParseLiteral(xmlXPathParserContextPtr ctxt) {
10277 * @ctxt: the XPath Parser context
10287 xmlXPathCompLiteral(xmlXPathParserContextPtr ctxt) {
10318 xmlXPathCacheNewString(ctxt->context, ret), NULL);
10324 * @ctxt: the XPath Parser context
10340 xmlXPathCompVariableReference(xmlXPathParserContextPtr ctxt) {
10349 name = xmlXPathParseQName(ctxt, &prefix);
10354 ctxt->comp->last = -1;
10358 if ((ctxt->context != NULL) && (ctxt->context->flags & XML_XPATH_NOVAR)) {
10394 * @ctxt: the XPath Parser context
10403 xmlXPathCompFunctionCall(xmlXPathParserContextPtr ctxt) {
10409 name = xmlXPathParseQName(ctxt, &prefix);
10440 ctxt->comp->last = -1;
10443 int op1 = ctxt->comp->last;
10444 ctxt->comp->last = -1;
10445 xmlXPathCompileExpr(ctxt, sort);
10446 if (ctxt->error != XPATH_EXPRESSION_OK) {
10451 PUSH_BINARY_EXPR(XPATH_OP_ARG, op1, ctxt->comp->last, 0, 0);
10471 * @ctxt: the XPath Parser context
10482 xmlXPathCompPrimaryExpr(xmlXPathParserContextPtr ctxt) {
10484 if (CUR == '$') xmlXPathCompVariableReference(ctxt);
10488 xmlXPathCompileExpr(ctxt, 1);
10496 xmlXPathCompNumber(ctxt);
10498 xmlXPathCompLiteral(ctxt);
10500 xmlXPathCompFunctionCall(ctxt);
10507 * @ctxt: the XPath Parser context
10521 xmlXPathCompFilterExpr(xmlXPathParserContextPtr ctxt) {
10522 xmlXPathCompPrimaryExpr(ctxt);
10527 xmlXPathCompPredicate(ctxt, 1);
10536 * @ctxt: the XPath Parser context
10552 xmlXPathScanName(xmlXPathParserContextPtr ctxt) {
10558 cur = ctxt->cur;
10577 ret = xmlStrndup(cur, ctxt->cur - cur);
10578 ctxt->cur = cur;
10584 * @ctxt: the XPath Parser context
10601 xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
10636 name = xmlXPathScanName(ctxt);
10676 } else if (ctxt->xptr &&
10727 xmlXPathCompLocationPath(ctxt);
10729 xmlXPathCompFilterExpr(ctxt);
10737 PUSH_UNARY_EXPR(XPATH_OP_RESET, ctxt->comp->last, 1, 0);
10739 xmlXPathCompRelativeLocationPath(ctxt);
10741 xmlXPathCompRelativeLocationPath(ctxt);
10749 * @ctxt: the XPath Parser context
10758 xmlXPathCompUnionExpr(xmlXPathParserContextPtr ctxt) {
10759 xmlXPathCompPathExpr(ctxt);
10763 int op1 = ctxt->comp->last;
10768 xmlXPathCompPathExpr(ctxt);
10770 PUSH_BINARY_EXPR(XPATH_OP_UNION, op1, ctxt->comp->last, 0, 0);
10778 * @ctxt: the XPath Parser context
10787 xmlXPathCompUnaryExpr(xmlXPathParserContextPtr ctxt) {
10799 xmlXPathCompUnionExpr(ctxt);
10803 PUSH_UNARY_EXPR(XPATH_OP_PLUS, ctxt->comp->last, 2, 0);
10805 PUSH_UNARY_EXPR(XPATH_OP_PLUS, ctxt->comp->last, 3, 0);
10811 * @ctxt: the XPath Parser context
10823 xmlXPathCompMultiplicativeExpr(xmlXPathParserContextPtr ctxt) {
10824 xmlXPathCompUnaryExpr(ctxt);
10831 int op1 = ctxt->comp->last;
10844 xmlXPathCompUnaryExpr(ctxt);
10846 PUSH_BINARY_EXPR(XPATH_OP_MULT, op1, ctxt->comp->last, op, 0);
10853 * @ctxt: the XPath Parser context
10863 xmlXPathCompAdditiveExpr(xmlXPathParserContextPtr ctxt) {
10865 xmlXPathCompMultiplicativeExpr(ctxt);
10870 int op1 = ctxt->comp->last;
10876 xmlXPathCompMultiplicativeExpr(ctxt);
10878 PUSH_BINARY_EXPR(XPATH_OP_PLUS, op1, ctxt->comp->last, plus, 0);
10885 * @ctxt: the XPath Parser context
10902 xmlXPathCompRelationalExpr(xmlXPathParserContextPtr ctxt) {
10903 xmlXPathCompAdditiveExpr(ctxt);
10911 int op1 = ctxt->comp->last;
10920 xmlXPathCompAdditiveExpr(ctxt);
10922 PUSH_BINARY_EXPR(XPATH_OP_CMP, op1, ctxt->comp->last, inf, strict);
10929 * @ctxt: the XPath Parser context
10944 xmlXPathCompEqualityExpr(xmlXPathParserContextPtr ctxt) {
10945 xmlXPathCompRelationalExpr(ctxt);
10950 int op1 = ctxt->comp->last;
10957 xmlXPathCompRelationalExpr(ctxt);
10959 PUSH_BINARY_EXPR(XPATH_OP_EQUAL, op1, ctxt->comp->last, eq, 0);
10966 * @ctxt: the XPath Parser context
10975 xmlXPathCompAndExpr(xmlXPathParserContextPtr ctxt) {
10976 xmlXPathCompEqualityExpr(ctxt);
10980 int op1 = ctxt->comp->last;
10983 xmlXPathCompEqualityExpr(ctxt);
10985 PUSH_BINARY_EXPR(XPATH_OP_AND, op1, ctxt->comp->last, 0, 0);
10992 * @ctxt: the XPath Parser context
11001 xmlXPathCompileExpr(xmlXPathParserContextPtr ctxt, int sort) {
11002 xmlXPathCompAndExpr(ctxt);
11006 int op1 = ctxt->comp->last;
11009 xmlXPathCompAndExpr(ctxt);
11011 PUSH_BINARY_EXPR(XPATH_OP_OR, op1, ctxt->comp->last, 0, 0);
11014 if ((sort) && (ctxt->comp->steps[ctxt->comp->last].op != XPATH_OP_VALUE)) {
11021 PUSH_UNARY_EXPR(XPATH_OP_SORT, ctxt->comp->last , 0, 0);
11027 * @ctxt: the XPath Parser context
11036 xmlXPathCompPredicate(xmlXPathParserContextPtr ctxt, int filter) {
11037 int op1 = ctxt->comp->last;
11046 ctxt->comp->last = -1;
11057 xmlXPathCompileExpr(ctxt, 0);
11059 xmlXPathCompileExpr(ctxt, 1);
11067 PUSH_BINARY_EXPR(XPATH_OP_FILTER, op1, ctxt->comp->last, 0, 0);
11069 PUSH_BINARY_EXPR(XPATH_OP_PREDICATE, op1, ctxt->comp->last, 0, 0);
11077 * @ctxt: the XPath Parser context
11097 xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
11121 name = xmlXPathParseNCName(ctxt);
11158 name = xmlXPathParseLiteral(ctxt);
11184 *prefix = xmlXPathNsLookup(ctxt->context, name);
11203 name = xmlXPathParseNCName(ctxt);
11281 * @ctxt: the XPath Parser context
11312 xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
11339 if (ctxt->xptr) {
11340 name = xmlXPathParseNCName(ctxt);
11342 op2 = ctxt->comp->last;
11351 xmlXPathCompileExpr(ctxt, 1);
11352 /* PUSH_BINARY_EXPR(XPATH_OP_RANGETO, op2, ctxt->comp->last, 0, 0); */
11369 name = xmlXPathParseNCName(ctxt);
11393 if (ctxt->error != XPATH_EXPRESSION_OK) {
11398 name = xmlXPathCompNodeTest(ctxt, &test, &type, &prefix, name);
11402 if ((prefix != NULL) && (ctxt->context != NULL) &&
11403 (ctxt->context->flags & XML_XPATH_CHECKNS)) {
11404 if (xmlXPathNsLookup(ctxt->context, prefix) == NULL) {
11405 xmlXPathErr(ctxt, XPATH_UNDEF_PREFIX_ERROR);
11415 if (ctxt->value == NULL)
11417 else if (ctxt->value->nodesetval == NULL)
11420 xmlGenericErrorContextNodeSet(stdout, ctxt->value->nodesetval);
11426 op1 = ctxt->comp->last;
11427 ctxt->comp->last = -1;
11431 xmlXPathCompPredicate(ctxt, 0);
11439 PUSH_FULL_EXPR(XPATH_OP_COLLECT, op1, ctxt->comp->last, axis,
11445 if (ctxt->value == NULL)
11447 else if (ctxt->value->nodesetval == NULL)
11451 ctxt->value->nodesetval);
11457 * @ctxt: the XPath Parser context
11468 (xmlXPathParserContextPtr ctxt) {
11479 xmlXPathCompStep(ctxt);
11488 xmlXPathCompStep(ctxt);
11492 xmlXPathCompStep(ctxt);
11500 * @ctxt: the XPath Parser context
11520 xmlXPathCompLocationPath(xmlXPathParserContextPtr ctxt) {
11523 xmlXPathCompRelativeLocationPath(ctxt);
11531 xmlXPathCompRelativeLocationPath(ctxt);
11538 xmlXPathCompRelativeLocationPath(ctxt);
11552 xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op);
11642 xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt,
11649 xmlXPathCompExprPtr comp = ctxt->comp;
11658 contextSize = xmlXPathCompOpEvalPredicate(ctxt,
11665 xmlXPathContextPtr xpctxt = ctxt->context;
11707 exprOp = &ctxt->comp->steps[op->ch2];
11735 ctxt->error = XPATH_MEMORY_ERROR;
11740 valuePush(ctxt, contextObj);
11742 res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1);
11744 if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) {
11760 if (ctxt->value == contextObj) {
11766 valuePop(ctxt);
11778 if (ctxt->value == contextObj)
11779 valuePop(ctxt);
11784 xmlXPathReleaseObject(ctxt->context, exprRes);
11798 xmlXPathCompOpEvalPositionalPredicate(xmlXPathParserContextPtr ctxt,
11807 xmlXPathCompExprPtr comp = ctxt->comp;
11813 contextSize = xmlXPathCompOpEvalPredicate(ctxt,
11838 xmlXPathContextPtr xpctxt = ctxt->context;
11857 exprOp = &ctxt->comp->steps[op->ch2];
11887 ctxt->error = XPATH_MEMORY_ERROR;
11892 valuePush(ctxt, contextObj);
11893 frame = xmlXPathSetFrame(ctxt);
11894 res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1);
11895 xmlXPathPopFrame(ctxt, frame);
11896 tmp = valuePop(ctxt);
11898 if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) {
11905 tmp = valuePop(ctxt);
11910 valuePush(ctxt, tmp);
11952 xmlXPathReleaseObject(ctxt->context, exprRes);
11955 if (ctxt->value == contextObj) {
11961 valuePop(ctxt);
11979 if (ctxt->value == contextObj)
11980 valuePop(ctxt);
11984 xmlXPathReleaseObject(ctxt->context, exprRes);
11998 xmlXPathIsPositionalPredicate(xmlXPathParserContextPtr ctxt,
12022 exprOp = &ctxt->comp->steps[op->ch2];
12054 xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
12064 ctxt->error = XPATH_MEMORY_ERROR; \
12068 ctxt->error = XPATH_MEMORY_ERROR; \
12076 ctxt->error = XPATH_MEMORY_ERROR; \
12081 ctxt->error = XPATH_MEMORY_ERROR; \
12119 xmlXPathContextPtr xpctxt = ctxt->context;
12123 obj = valuePop(ctxt);
12230 valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, NULL));
12259 predOp = &ctxt->comp->steps[op->ch2];
12260 if (xmlXPathIsPositionalPredicate(ctxt, predOp, &maxPos)) {
12265 predOp = &ctxt->comp->steps[predOp->ch1];
12299 (ctxt->error == XPATH_EXPRESSION_OK)) {
12316 cur = next(ctxt, cur);
12508 } while ((cur != NULL) && (ctxt->error == XPATH_EXPRESSION_OK));
12549 if (ctxt->error != XPATH_EXPRESSION_OK)
12562 * (E.g. ctxt->value->type == XPATH_LOCATIONSET)
12586 newSize = xmlXPathCompOpEvalPositionalPredicate(ctxt,
12589 newSize = xmlXPathCompOpEvalPredicate(ctxt,
12592 if (ctxt->error != XPATH_EXPRESSION_OK) {
12648 ctxt->value->boolval = 1;
12649 ctxt->value->user = obj->user;
12672 valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, outSeq));
12696 xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
12701 * @ctxt: the XPath parser context with the compiled expression
12711 xmlXPathCompOpEvalFirst(xmlXPathParserContextPtr ctxt,
12719 comp = ctxt->comp;
12725 xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch1],
12728 if ((ctxt->value != NULL)
12729 && (ctxt->value->type == XPATH_NODESET)
12730 && (ctxt->value->nodesetval != NULL)
12731 && (ctxt->value->nodesetval->nodeNr >= 1)) {
12742 if (ctxt->value->nodesetval->nodeNr > 1)
12743 xmlXPathNodeSetSort(ctxt->value->nodesetval);
12744 *first = ctxt->value->nodesetval->nodeTab[0];
12747 xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch2],
12751 arg2 = valuePop(ctxt);
12752 arg1 = valuePop(ctxt);
12755 xmlXPathReleaseObject(ctxt->context, arg1);
12756 xmlXPathReleaseObject(ctxt->context, arg2);
12762 valuePush(ctxt, arg1);
12763 xmlXPathReleaseObject(ctxt->context, arg2);
12769 xmlXPathRoot(ctxt);
12773 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12776 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12778 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
12779 ctxt->context->node));
12783 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12786 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12788 ctxt->context->node = NULL;
12794 total = xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12797 total += xmlXPathNodeCollectAndTest(ctxt, op, first, NULL, 0);
12801 valuePush(ctxt,
12802 xmlXPathCacheObjectCopy(ctxt->context,
12808 xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch1],
12811 if ((ctxt->value != NULL)
12812 && (ctxt->value->type == XPATH_NODESET)
12813 && (ctxt->value->nodesetval != NULL)
12814 && (ctxt->value->nodesetval->nodeNr > 1))
12815 xmlXPathNodeSetSort(ctxt->value->nodesetval);
12819 total += xmlXPathCompOpEvalFilterFirst(ctxt, op, first);
12823 return (xmlXPathCompOpEval(ctxt, op));
12829 * @ctxt: the XPath parser context with the compiled expression
12839 xmlXPathCompOpEvalLast(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op,
12851 comp = ctxt->comp;
12856 bakd = ctxt->context->doc;
12857 bak = ctxt->context->node;
12858 pp = ctxt->context->proximityPosition;
12859 cs = ctxt->context->contextSize;
12861 xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch1], last);
12863 if ((ctxt->value != NULL)
12864 && (ctxt->value->type == XPATH_NODESET)
12865 && (ctxt->value->nodesetval != NULL)
12866 && (ctxt->value->nodesetval->nodeNr >= 1)) {
12870 if (ctxt->value->nodesetval->nodeNr > 1)
12871 xmlXPathNodeSetSort(ctxt->value->nodesetval);
12873 ctxt->value->nodesetval->nodeTab[ctxt->value->
12877 ctxt->context->doc = bakd;
12878 ctxt->context->node = bak;
12879 ctxt->context->proximityPosition = pp;
12880 ctxt->context->contextSize = cs;
12882 xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch2], last);
12884 if ((ctxt->value != NULL)
12885 && (ctxt->value->type == XPATH_NODESET)
12886 && (ctxt->value->nodesetval != NULL)
12887 && (ctxt->value->nodesetval->nodeNr >= 1)) { /* TODO: NOP ? */
12890 arg2 = valuePop(ctxt);
12891 arg1 = valuePop(ctxt);
12894 xmlXPathReleaseObject(ctxt->context, arg1);
12895 xmlXPathReleaseObject(ctxt->context, arg2);
12901 valuePush(ctxt, arg1);
12902 xmlXPathReleaseObject(ctxt->context, arg2);
12908 xmlXPathRoot(ctxt);
12912 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12915 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12917 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
12918 ctxt->context->node));
12922 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12925 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12927 ctxt->context->node = NULL;
12933 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12936 total += xmlXPathNodeCollectAndTest(ctxt, op, NULL, last, 0);
12940 valuePush(ctxt,
12941 xmlXPathCacheObjectCopy(ctxt->context,
12947 xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch1],
12950 if ((ctxt->value != NULL)
12951 && (ctxt->value->type == XPATH_NODESET)
12952 && (ctxt->value->nodesetval != NULL)
12953 && (ctxt->value->nodesetval->nodeNr > 1))
12954 xmlXPathNodeSetSort(ctxt->value->nodesetval);
12957 return (xmlXPathCompOpEval(ctxt, op));
12963 xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
12976 comp = ctxt->comp;
12995 xmlXPathCompOpEvalLast(ctxt,
13003 if ((ctxt->value != NULL) &&
13004 (ctxt->value->type == XPATH_NODESET) &&
13005 (ctxt->value->nodesetval != NULL) &&
13006 (ctxt->value->nodesetval->nodeTab != NULL) &&
13007 (ctxt->value->nodesetval->nodeNr > 1)) {
13008 xmlXPathNodeSetKeepLast(ctxt->value->nodesetval);
13009 *first = *(ctxt->value->nodesetval->nodeTab);
13016 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13020 if (ctxt->value == NULL)
13024 oldnode = ctxt->context->node;
13028 if (ctxt->value->type == XPATH_LOCATIONSET) {
13039 obj = valuePop(ctxt);
13041 ctxt->context->node = NULL;
13044 ctxt->context->contextSize = 0;
13045 ctxt->context->proximityPosition = 0;
13047 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13048 res = valuePop(ctxt);
13050 xmlXPathReleaseObject(ctxt->context, res);
13052 valuePush(ctxt, obj);
13063 ctxt->context->node = oldlocset->locTab[i]->user;
13064 ctxt->context->contextSize = oldlocset->locNr;
13065 ctxt->context->proximityPosition = i + 1;
13067 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
13068 ctxt->context->node);
13071 ctxt->context->node) < 0) {
13072 ctxt->error = XPATH_MEMORY_ERROR;
13075 valuePush(ctxt, tmp);
13077 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13078 if (ctxt->error != XPATH_EXPRESSION_OK) {
13086 res = valuePop(ctxt);
13087 if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
13089 xmlXPathCacheObjectCopy(ctxt->context,
13096 xmlXPathReleaseObject(ctxt->context, res);
13098 if (ctxt->value == tmp) {
13099 valuePop(ctxt);
13108 ctxt->context->node = NULL;
13118 xmlXPathReleaseObject(ctxt->context, tmp);
13123 xmlXPathReleaseObject(ctxt->context, obj);
13124 ctxt->context->node = NULL;
13125 ctxt->context->contextSize = -1;
13126 ctxt->context->proximityPosition = -1;
13127 valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
13128 ctxt->context->node = oldnode;
13139 obj = valuePop(ctxt);
13142 oldnode = ctxt->context->node;
13143 oldDoc = ctxt->context->doc;
13144 ctxt->context->node = NULL;
13147 ctxt->context->contextSize = 0;
13148 ctxt->context->proximityPosition = 0;
13152 xmlXPathCompOpEval(ctxt,
13155 res = valuePop(ctxt);
13159 valuePush(ctxt, obj);
13160 ctxt->context->node = oldnode;
13178 ctxt->context->node = oldset->nodeTab[i];
13181 ctxt->context->doc = oldset->nodeTab[i]->doc;
13183 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
13184 ctxt->context->node);
13187 ctxt->context->node) < 0) {
13188 ctxt->error = XPATH_MEMORY_ERROR;
13191 valuePush(ctxt, tmp);
13192 ctxt->context->contextSize = oldset->nodeNr;
13193 ctxt->context->proximityPosition = i + 1;
13195 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13196 if (ctxt->error != XPATH_EXPRESSION_OK) {
13205 res = valuePop(ctxt);
13206 if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
13208 ctxt->error = XPATH_MEMORY_ERROR;
13214 xmlXPathReleaseObject(ctxt->context, res);
13216 if (ctxt->value == tmp) {
13217 valuePop(ctxt);
13226 ctxt->context->node = NULL;
13236 xmlXPathReleaseObject(ctxt->context, tmp);
13241 xmlXPathReleaseObject(ctxt->context, obj);
13242 ctxt->context->node = NULL;
13243 ctxt->context->contextSize = -1;
13244 ctxt->context->proximityPosition = -1;
13246 ctxt->context->doc = oldDoc;
13247 valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, newset));
13249 ctxt->context->node = oldnode;
13256 * @ctxt: the XPath parser context with the compiled expression
13263 xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
13275 comp = ctxt->comp;
13280 bakd = ctxt->context->doc;
13281 bak = ctxt->context->node;
13282 pp = ctxt->context->proximityPosition;
13283 cs = ctxt->context->contextSize;
13284 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13286 xmlXPathBooleanFunction(ctxt, 1);
13287 if ((ctxt->value == NULL) || (ctxt->value->boolval == 0))
13289 arg2 = valuePop(ctxt);
13290 ctxt->context->doc = bakd;
13291 ctxt->context->node = bak;
13292 ctxt->context->proximityPosition = pp;
13293 ctxt->context->contextSize = cs;
13294 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13295 if (ctxt->error) {
13299 xmlXPathBooleanFunction(ctxt, 1);
13300 arg1 = valuePop(ctxt);
13302 valuePush(ctxt, arg1);
13303 xmlXPathReleaseObject(ctxt
13306 bakd = ctxt->context->doc;
13307 bak = ctxt->context->node;
13308 pp = ctxt->context->proximityPosition;
13309 cs = ctxt->context->contextSize;
13310 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13312 xmlXPathBooleanFunction(ctxt, 1);
13313 if ((ctxt->value == NULL) || (ctxt->value->boolval == 1))
13315 arg2 = valuePop(ctxt);
13316 ctxt->context->doc = bakd;
13317 ctxt->context->node = bak;
13318 ctxt->context->proximityPosition = pp;
13319 ctxt->context->contextSize = cs;
13320 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13321 if (ctxt->error) {
13325 xmlXPathBooleanFunction(ctxt, 1);
13326 arg1 = valuePop(ctxt);
13328 valuePush(ctxt, arg1);
13329 xmlXPathReleaseObject(ctxt->context, arg2);
13332 bakd = ctxt->context->doc;
13333 bak = ctxt->context->node;
13334 pp = ctxt->context->proximityPosition;
13335 cs = ctxt->context->contextSize;
13336 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13338 ctxt->context->doc = bakd;
13339 ctxt->context->node = bak;
13340 ctxt->context->proximityPosition = pp;
13341 ctxt->context->contextSize = cs;
13342 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13345 equal = xmlXPathEqualValues(ctxt);
13347 equal = xmlXPathNotEqualValues(ctxt);
13348 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, equal));
13351 bakd = ctxt->context->doc;
13352 bak = ctxt->context->node;
13353 pp = ctxt->context->proximityPosition;
13354 cs = ctxt->context->contextSize;
13355 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13357 ctxt->context->doc = bakd;
13358 ctxt->context->node = bak;
13359 ctxt->context->proximityPosition = pp;
13360 ctxt->context->contextSize = cs;
13361 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13363 ret = xmlXPathCompareValues(ctxt, op->value, op->value2);
13364 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, ret));
13367 bakd = ctxt->context->doc;
13368 bak = ctxt->context->node;
13369 pp = ctxt->context->proximityPosition;
13370 cs = ctxt->context->contextSize;
13371 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13374 ctxt->context->doc = bakd;
13375 ctxt->context->node = bak;
13376 ctxt->context->proximityPosition = pp;
13377 ctxt->context->contextSize = cs;
13378 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13382 xmlXPathSubValues(ctxt);
13384 xmlXPathAddValues(ctxt);
13386 xmlXPathValueFlipSign(ctxt);
13393 bakd = ctxt->context->doc;
13394 bak = ctxt->context->node;
13395 pp = ctxt->context->proximityPosition;
13396 cs = ctxt->context->contextSize;
13397 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13399 ctxt->context->doc = bakd;
13400 ctxt->context->node = bak;
13401 ctxt->context->proximityPosition = pp;
13402 ctxt->context->contextSize = cs;
13403 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13406 xmlXPathMultValues(ctxt);
13408 xmlXPathDivValues(ctxt);
13410 xmlXPathModValues(ctxt);
13413 bakd = ctxt->context->doc;
13414 bak = ctxt->context->node;
13415 pp = ctxt->context->proximityPosition;
13416 cs = ctxt->context->contextSize;
13417 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13419 ctxt->context->doc = bakd;
13420 ctxt->context->node = bak;
13421 ctxt->context->proximityPosition = pp;
13422 ctxt->context->contextSize = cs;
13423 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13426 arg2 = valuePop(ctxt);
13427 arg1 = valuePop(ctxt);
13430 xmlXPathReleaseObject(ctxt->context, arg1);
13431 xmlXPathReleaseObject(ctxt->context, arg2);
13443 valuePush(ctxt, arg1);
13444 xmlXPathReleaseObject(ctxt->context, arg2);
13447 xmlXPathRoot(ctxt);
13451 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13454 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13456 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
13457 ctxt->context->node));
13461 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13464 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13466 ctxt->context->node = NULL;
13472 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13475 total += xmlXPathNodeCollectAndTest(ctxt, op, NULL, NULL, 0);
13479 valuePush(ctxt,
13480 xmlXPathCacheObjectCopy(ctxt->context,
13488 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13490 val = xmlXPathVariableLookup(ctxt->context, op->value4);
13493 valuePush(ctxt, val);
13497 URI = xmlXPathNsLookup(ctxt->context, op->value5);
13502 ctxt->error = XPATH_UNDEF_PREFIX_ERROR;
13505 val = xmlXPathVariableLookupNS(ctxt->context,
13509 valuePush(ctxt, val);
13519 frame = xmlXPathSetFrame(ctxt);
13522 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13523 if (ctxt->error != XPATH_EXPRESSION_OK) {
13524 xmlXPathPopFrame(ctxt, frame);
13528 if (ctxt->valueNr < ctxt->valueFrame + op->value) {
13531 ctxt->error = XPATH_INVALID_OPERAND;
13532 xmlXPathPopFrame(ctxt, frame);
13536 if (ctxt->valueTab[(ctxt->valueNr - 1) - i] == NULL) {
13539 ctxt->error = XPATH_INVALID_OPERAND;
13540 xmlXPathPopFrame(ctxt, frame);
13551 xmlXPathFunctionLookup(ctxt->context,
13554 URI = xmlXPathNsLookup(ctxt->context, op->value5);
13559 xmlXPathPopFrame(ctxt, frame);
13560 ctxt->error = XPATH_UNDEF_PREFIX_ERROR;
13563 func = xmlXPathFunctionLookupNS(ctxt->context,
13575 oldFunc = ctxt->context->function;
13576 oldFuncURI = ctxt->context->functionURI;
13577 ctxt->context->function = op->value4;
13578 ctxt->context->functionURI = op->cacheURI;
13579 func(ctxt, op->value);
13580 ctxt->context->function = oldFunc;
13581 ctxt->context->functionURI = oldFuncURI;
13582 xmlXPathPopFrame(ctxt, frame);
13586 bakd = ctxt->context->doc;
13587 bak = ctxt->context->node;
13588 pp = ctxt->context->proximityPosition;
13589 cs = ctxt->context->contextSize;
13591 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13592 ctxt->context->contextSize = cs;
13593 ctxt->context->proximityPosition = pp;
13594 ctxt->context->node = bak;
13595 ctxt->context->doc = bakd;
13599 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13600 ctxt->context->contextSize = cs;
13601 ctxt->context->proximityPosition = pp;
13602 ctxt->context->node = bak;
13603 ctxt->context->doc = bakd;
13645 xmlXPathCompOpEvalFirst(ctxt,
13653 if ((ctxt->value != NULL) &&
13654 (ctxt->value->type == XPATH_NODESET) &&
13655 (ctxt->value->nodesetval != NULL) &&
13656 (ctxt->value->nodesetval->nodeNr > 1))
13657 xmlXPathNodeSetClearFromPos(ctxt->value->nodesetval,
13680 xmlXPathCompOpEvalLast(ctxt,
13688 if ((ctxt->value != NULL) &&
13689 (ctxt->value->type == XPATH_NODESET) &&
13690 (ctxt->value->nodesetval != NULL) &&
13691 (ctxt->value->nodesetval->nodeTab != NULL) &&
13692 (ctxt->value->nodesetval->nodeNr > 1))
13693 xmlXPathNodeSetKeepLast(ctxt->value->nodesetval);
13710 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13714 if (ctxt->value == NULL)
13717 ctxt->context->node;
13723 if (ctxt->value->type == XPATH_LOCATIONSET) {
13733 obj = valuePop(ctxt);
13735 ctxt->context->node = NULL;
13738 ctxt->context->contextSize = 0;
13739 ctxt->context->proximityPosition = 0;
13742 xmlXPathCompOpEval(ctxt,
13744 res = valuePop(ctxt);
13746 xmlXPathReleaseObject(ctxt->context, res);
13748 valuePush(ctxt, obj);
13759 ctxt->context->node = oldlocset->locTab[i]->user;
13760 ctxt->context->contextSize = oldlocset->locNr;
13761 ctxt->context->proximityPosition = i + 1;
13762 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
13763 ctxt->context->node);
13764 valuePush(ctxt, tmp);
13768 xmlXPathCompOpEval(ctxt,
13770 if (ctxt->error != XPATH_EXPRESSION_OK) {
13779 res = valuePop(ctxt);
13780 if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
13790 xmlXPathReleaseObject(ctxt->context, res);
13792 if (ctxt->value == tmp) {
13793 res = valuePop(ctxt);
13794 xmlXPathReleaseObject(ctxt->context, res);
13797 ctxt->context->node = NULL;
13803 xmlXPathReleaseObject(ctxt->context, obj);
13804 ctxt->context->node = NULL;
13805 ctxt->context->contextSize = -1;
13806 ctxt->context->proximityPosition = -1;
13807 valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
13808 ctxt->context->node = oldnode;
13819 obj = valuePop(ctxt);
13822 oldnode = ctxt->context->node;
13823 oldDoc = ctxt->context->doc;
13824 ctxt->context->node = NULL;
13827 ctxt->context->contextSize = 0;
13828 ctxt->context->proximityPosition = 0;
13832 xmlXPathCompOpEval(ctxt,
13835 res = valuePop(ctxt);
13839 valuePush(ctxt, obj);
13840 ctxt->context->node = oldnode;
13881 ctxt->context->node = oldset->nodeTab[i];
13884 ctxt->context->doc = oldset->nodeTab[i]->doc;
13886 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
13887 ctxt->context->node);
13890 ctxt->context->node) < 0) {
13891 ctxt->error = XPATH_MEMORY_ERROR;
13894 valuePush(ctxt, tmp);
13895 ctxt->context->contextSize = oldset->nodeNr;
13896 ctxt->context->proximityPosition = i + 1;
13904 xmlXPathCompOpEval(ctxt,
13906 if (ctxt->error != XPATH_EXPRESSION_OK) {
13920 res = valuePop(ctxt);
13921 if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
13924 ctxt->error = XPATH_MEMORY_ERROR;
13931 xmlXPathReleaseObject(ctxt->context, res);
13933 if (ctxt->value == tmp) {
13934 valuePop(ctxt);
13943 ctxt->context->node = NULL;
13946 xmlXPathReleaseObject(ctxt->context, tmp);
13950 xmlXPathReleaseObject(ctxt->context, obj);
13951 ctxt->context->node = NULL;
13952 ctxt->context->contextSize = -1;
13953 ctxt->context->proximityPosition = -1;
13955 ctxt->context->doc = oldDoc;
13956 valuePush(ctxt,
13957 xmlXPathCacheWrapNodeSet(ctxt->context, newset));
13959 ctxt->context->node = oldnode;
13964 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13966 if ((ctxt->value != NULL) &&
13967 (ctxt->value->type == XPATH_NODESET) &&
13968 (ctxt->value->nodesetval != NULL) &&
13969 (ctxt->value->nodesetval->nodeNr > 1))
13971 xmlXPathNodeSetSort(ctxt->value->nodesetval);
13986 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13989 if (ctxt->value == NULL) {
13995 if (ctxt->value->type == XPATH_LOCATIONSET) {
14002 obj = valuePop(ctxt);
14006 ctxt->context->node = NULL;
14007 ctxt->context->contextSize = 0;
14008 ctxt->context->proximityPosition = 0;
14009 total += xmlXPathCompOpEval(ctxt,&comp->steps[op->ch2]);
14010 res = valuePop(ctxt);
14012 xmlXPathReleaseObject(ctxt->context, res);
14014 valuePush(ctxt, obj);
14025 ctxt->context->node = oldlocset->locTab[i]->user;
14026 ctxt->context->contextSize = oldlocset->locNr;
14027 ctxt->context->proximityPosition = i + 1;
14028 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
14029 ctxt->context->node);
14030 valuePush(ctxt, tmp);
14034 xmlXPathCompOpEval(ctxt,
14036 if (ctxt->error != XPATH_EXPRESSION_OK) {
14041 res = valuePop(ctxt);
14067 xmlXPathReleaseObject(ctxt->context, res);
14069 if (ctxt->value == tmp) {
14070 res = valuePop(ctxt);
14071 xmlXPathReleaseObject(ctxt->context, res);
14074 ctxt->context->node = NULL;
14078 obj = valuePop(ctxt);
14080 ctxt->context->node = NULL;
14090 ctxt->context->node = oldset->nodeTab[i];
14094 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
14095 ctxt->context->node);
14096 valuePush(ctxt, tmp);
14100 xmlXPathCompOpEval(ctxt,
14102 if (ctxt->error != XPATH_EXPRESSION_OK) {
14107 res = valuePop(ctxt);
14119 xmlXPathReleaseObject(ctxt->context, res);
14121 if (ctxt->value == tmp) {
14122 res = valuePop(ctxt);
14123 xmlXPathReleaseObject(ctxt->context, res);
14126 ctxt->context->node = NULL;
14134 xmlXPathReleaseObject(ctxt->context, obj);
14135 ctxt->context->node = NULL;
14136 ctxt->context->contextSize = -1;
14137 ctxt->context->proximityPosition = -1;
14138 valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
14145 ctxt->error = XPATH_INVALID_OPERAND;
14151 * @ctxt: the XPath parser context
14158 xmlXPathCompOpEvalToBoolean(xmlXPathParserContextPtr ctxt,
14165 /* comp = ctxt->comp; */
14172 return(xmlXPathEvaluatePredicateResult(ctxt, resObj));
14179 op = &ctxt->comp->steps[op->ch1];
14187 xmlXPathCompOpEval(ctxt, &ctxt->comp->steps[op->ch1]);
14188 if (ctxt->error != XPATH_EXPRESSION_OK)
14191 xmlXPathNodeCollectAndTest(ctxt, op, NULL, NULL, 1);
14192 if (ctxt->error != XPATH_EXPRESSION_OK)
14195 resObj = valuePop(ctxt);
14203 xmlXPathCompOpEval(ctxt, op);
14204 if (ctxt->error != XPATH_EXPRESSION_OK)
14207 resObj = valuePop(ctxt);
14227 res = xmlXPathEvaluatePredicateResult(ctxt, resObj);
14231 xmlXPathReleaseObject(ctxt->context, resObj);
14241 * @ctxt: the XPath parser context with the compiled expression
14246 xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp,
14258 if ((ctxt == NULL) || (comp == NULL))
14278 *resultSeq = xmlXPathCacheNewNodeSet(ctxt, NULL);
14292 (xmlNodePtr) ctxt->doc);
14297 xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, ctxt->node);
14305 cur = (xmlNodePtr)ctxt->doc;
14306 } else if (ctxt->node != NULL) {
14307 switch (ctxt->node->type) {
14315 cur = ctxt->node;
14387 ctxt->lastError.domain = XML_FROM_XPATH;
14388 ctxt->lastError.code = XML_ERR_NO_MEMORY;
14474 * @ctxt: the XPath parser context with the compiled expression
14480 xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
14484 if ((ctxt == NULL) || (ctxt->comp == NULL))
14487 if (ctxt->valueTab == NULL) {
14489 ctxt->valueTab = (xmlXPathObjectPtr *)
14491 if (ctxt->valueTab == NULL) {
14492 xmlXPathPErrMemory(ctxt, "creating evaluation context\n");
14493 xmlFree(ctxt);
14495 ctxt->valueNr = 0;
14496 ctxt->valueMax = 10;
14497 ctxt->value = NULL;
14498 ctxt->valueFrame = 0;
14501 if (ctxt->comp->stream) {
14508 res = xmlXPathRunStreamEval(ctxt->context,
14509 ctxt->comp->stream, NULL, 1);
14518 res = xmlXPathRunStreamEval(ctxt->context,
14519 ctxt->comp->stream, &resObj, 0);
14522 valuePush(ctxt, resObj);
14526 xmlXPathReleaseObject(ctxt->context, resObj);
14534 comp = ctxt->comp;
14541 return(xmlXPathCompOpEvalToBoolean(ctxt,
14544 xmlXPathCompOpEval(ctxt, &comp->steps[comp->last]);
14557 * @ctxt: the XPath context
14572 xmlXPathEvalPredicate(xmlXPathContextPtr ctxt, xmlXPathObjectPtr res) {
14573 if ((ctxt == NULL) || (res == NULL)) return(0);
14578 return(res->floatval == ctxt->proximityPosition);
14595 * @ctxt: the XPath Parser context
14610 xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
14612 if ((ctxt == NULL) || (res == NULL)) return(0);
14618 return((res->floatval == ctxt->context->proximityPosition) &&
14621 return(res->floatval == ctxt->context->proximityPosition);
14647 * @ctxt: an XPath context
14655 xmlXPathTryStreamCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
14682 ((ctxt == NULL) || (ctxt->nsNr == 0) || (tmp[1] == ':')))
14685 if (ctxt != NULL) {
14686 dict = ctxt->dict;
14687 if (ctxt->nsNr > 0) {
14688 namespaces = xmlMalloc(2 * (ctxt->nsNr + 1) * sizeof(xmlChar*));
14690 xmlXPathErrMemory(ctxt, "allocating namespaces array\n");
14693 for (i = 0, j = 0; (j < ctxt->nsNr); j++) {
14694 ns = ctxt->namespaces[j];
14711 xmlXPathErrMemory(ctxt, "allocating streamable expression\n");
14792 * @ctxt: an XPath context
14801 xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
14806 comp = xmlXPathTryStreamCompile(ctxt, str);
14813 pctxt = xmlXPathNewParserContext(str, ctxt);
14869 * @ctxt: the XPath context
14881 xmlXPathContextPtr ctxt,
14892 CHECK_CTXT_NEG(ctxt)
14911 pctxt = xmlXPathCompParserContext(comp, ctxt);
14932 xmlXPathReleaseObject(ctxt, resObj);
14965 * @ctxt: the XPath context
14975 xmlXPathContextPtr ctxt)
14977 return(xmlXPathCompiledEvalInternal(comp, ctxt, NULL, 1));
14982 * @ctxt: the XPath Parser context
14988 xmlXPathEvalExpr(xmlXPathParserContextPtr ctxt) {
14993 if (ctxt == NULL) return;
14996 comp = xmlXPathTryStreamCompile(ctxt->context, ctxt->base);
14998 if (ctxt->comp != NULL)
14999 xmlXPathFreeCompExpr(ctxt->comp);
15000 ctxt->comp = comp;
15004 xmlXPathCompileExpr(ctxt, 1);
15008 if (*ctxt->cur != 0)
15011 if ((ctxt->comp->nbStep > 1) && (ctxt->comp->last >= 0))
15012 xmlXPathOptimizeExpression(ctxt->comp,
15013 &ctxt->comp->steps[ctxt->comp->last]);
15016 xmlXPathRunEval(ctxt, 0);
15031 xmlXPathParserContextPtr ctxt;
15038 ctxt = xmlXPathNewParserContext(str, ctx);
15039 if (ctxt == NULL)
15041 xmlXPathEvalExpr(ctxt);
15043 if (ctxt->error != XPATH_EXPRESSION_OK) {
15046 res = valuePop(ctxt);
15050 } else if (ctxt->valueNr > 0) {
15053 ctxt->valueNr);
15057 xmlXPathFreeParserContext(ctxt);
15107 * @ctxt: the XPath context
15115 xmlXPathEvalExpression(const xmlChar *str, xmlXPathContextPtr ctxt) {
15116 return(xmlXPathEval(str, ctxt));
15126 * @ctxt: the XPath Parser context
15173 xmlXPathEscapeUriFunction(xmlXPathParserContextPtr ctxt, int nargs) {
15182 escape_reserved = xmlXPathPopBoolean(ctxt);
15185 str = valuePop(ctxt);
15227 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
15230 xmlXPathReleaseObject(ctxt->context, str);
15235 * @ctxt: the XPath context
15240 xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt)
15242 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"boolean",
15244 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"ceiling",
15246 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"count",
15248 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"concat",
15250 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"contains",
15252 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"id",
15254 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"false",
15256 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"floor",
15258 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"last",
15260 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"lang",
15262 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"local-name",
15264 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"not",
15266 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"name",
15268 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"namespace-uri",
15270 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"normalize-space",
15272 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"number",
15274 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"position",
15276 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"round",
15278 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"string",
15280 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"string-length",
15282 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"starts-with",
15284 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring",
15286 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring-before",
15288 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring-after",
15290 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"sum",
15292 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"true",
15294 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"translate",
15297 xmlXPathRegisterFuncNS(ctxt, (const xmlChar *)"escape-uri",