Home | History | Annotate | Download | only in libxml2

Lines Matching refs:ctxt

592     { xmlXPathErr(ctxt, X); return(NULL); }
629 * @ctxt: an XPath context
635 xmlXPathErrMemory(xmlXPathContextPtr ctxt, const char *extra)
637 if (ctxt != NULL) {
644 ctxt->lastError.message = (char *) xmlStrdup(buf);
646 ctxt->lastError.message = (char *)
649 ctxt->lastError.domain = XML_FROM_XPATH;
650 ctxt->lastError.code = XML_ERR_NO_MEMORY;
651 if (ctxt->error != NULL)
652 ctxt->error(ctxt->userData, &ctxt->lastError);
671 * @ctxt: an XPath parser context
677 xmlXPathPErrMemory(xmlXPathParserContextPtr ctxt, const char *extra)
679 if (ctxt == NULL)
682 ctxt->error = XPATH_MEMORY_ERROR;
683 xmlXPathErrMemory(ctxt->context, extra);
689 * @ctxt: a XPath parser context
695 xmlXPathErr(xmlXPathParserContextPtr ctxt, int error)
699 if (ctxt == NULL) {
708 ctxt->error = error;
709 if (ctxt->context == NULL) {
714 (const char *) ctxt->base, NULL, NULL,
715 ctxt->cur - ctxt->base, 0,
721 xmlResetError(&ctxt->context->lastError);
723 ctxt->context->lastError.domain = XML_FROM_XPATH;
724 ctxt->context->lastError.code = error + XML_XPATH_EXPRESSION_OK -
726 ctxt->context->lastError.level = XML_ERR_ERROR;
727 ctxt->context->lastError.str1 = (char *) xmlStrdup(ctxt->base);
728 ctxt->context->lastError.int1 = ctxt->cur - ctxt->base;
729 ctxt->context->lastError.node = ctxt->context->debugNode;
730 if (ctxt->context->error != NULL) {
731 ctxt->context->error(ctxt->context->userData,
732 &ctxt->context->lastError);
735 NULL, ctxt->context->debugNode, XML_FROM_XPATH,
738 (const char *) ctxt->base, NULL, NULL,
739 ctxt->cur - ctxt->base, 0,
747 * @ctxt: the XPath Parser context
755 xmlXPatherror(xmlXPathParserContextPtr ctxt, const char *file ATTRIBUTE_UNUSED,
757 xmlXPathErr(ctxt, no);
966 xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj);
968 xmlXPathCompOpEvalFirst(xmlXPathParserContextPtr ctxt,
971 xmlXPathCompOpEvalToBoolean(xmlXPathParserContextPtr ctxt,
1165 xmlXPathCompExprAdd(ctxt->comp, (op1), (op2), \
1168 xmlXPathCompExprAdd(ctxt->comp, ctxt->comp->last, -1, \
1172 xmlXPathCompExprAdd(ctxt->comp, -1, -1, (op), (val), (val2), 0 ,NULL ,NULL)
1175 xmlXPathCompExprAdd(ctxt->comp, (ch), -1, (op), (val), (val2), 0 ,NULL ,NULL)
1178 xmlXPathCompExprAdd(ctxt->comp, (ch1), (ch2), (op), \
1724 xmlXPathDebugObjUsageReset(xmlXPathContextPtr ctxt)
1726 if (ctxt != NULL) {
1727 if (ctxt->cache != NULL) {
1729 (xmlXPathContextCachePtr) ctxt->cache;
1796 xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
1801 if (ctxt != NULL) {
1802 if (ctxt->cache != NULL) {
1804 (xmlXPathContextCachePtr) ctxt->cache;
1950 xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
1955 if (ctxt != NULL) {
1956 if (ctxt->cache != NULL) {
1958 (xmlXPathContextCachePtr) ctxt->cache;
2039 xmlXPathDebugObjUsageDisplay(xmlXPathContextPtr ctxt)
2059 if (ctxt != NULL) {
2060 if (ctxt->cache != NULL) {
2062 (xmlXPathContextCachePtr) ctxt->cache;
2230 * @ctxt: the XPath context
2250 xmlXPathContextSetCache(xmlXPathContextPtr ctxt,
2255 if (ctxt == NULL)
2260 if (ctxt->cache == NULL) {
2261 ctxt->cache = xmlXPathNewCache();
2262 if (ctxt->cache == NULL)
2265 cache = (xmlXPathContextCachePtr) ctxt->cache;
2275 } else if (ctxt->cache != NULL) {
2276 xmlXPathFreeCache((xmlXPathContextCachePtr) ctxt->cache);
2277 ctxt->cache = NULL;
2284 * @ctxt: the XPath context
2293 xmlXPathCacheWrapNodeSet(xmlXPathContextPtr ctxt, xmlNodeSetPtr val)
2295 if ((ctxt != NULL) && (ctxt->cache != NULL)) {
2297 (xmlXPathContextCachePtr) ctxt->cache;
2309 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
2321 * @ctxt: the XPath context
2330 xmlXPathCacheWrapString(xmlXPathContextPtr ctxt, xmlChar *val)
2332 if ((ctxt != NULL) && (ctxt->cache != NULL)) {
2333 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2346 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2362 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2372 * @ctxt: the XPath context
2382 xmlXPathCacheNewNodeSet(xmlXPathContextPtr ctxt, xmlNodePtr val)
2384 if ((ctxt != NULL) && (ctxt->cache)) {
2385 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2409 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
2427 ctxt->lastError.domain = XML_FROM_XPATH;
2428 ctxt->lastError.code = XML_ERR_NO_MEMORY;
2432 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
2442 * @ctxt: the XPath context
2451 xmlXPathCacheNewCString(xmlXPathContextPtr ctxt, const char *val)
2453 if ((ctxt != NULL) && (ctxt->cache)) {
2454 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2467 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2481 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2491 * @ctxt: the XPath context
2500 xmlXPathCacheNewString(xmlXPathContextPtr ctxt, const xmlChar *val)
2502 if ((ctxt != NULL) && (ctxt->cache)) {
2503 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2518 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2535 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2545 * @ctxt: the XPath context
2554 xmlXPathCacheNewBoolean(xmlXPathContextPtr ctxt, int val)
2556 if ((ctxt != NULL) && (ctxt->cache)) {
2557 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2569 xmlXPathDebugObjUsageRequested(ctxt, XPATH_BOOLEAN);
2583 xmlXPathDebugObjUsageRequested(ctxt, XPATH_BOOLEAN);
2593 * @ctxt: the XPath context
2602 xmlXPathCacheNewFloat(xmlXPathContextPtr ctxt, double val)
2604 if ((ctxt != NULL) && (ctxt->cache)) {
2605 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2617 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NUMBER);
2631 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NUMBER);
2641 * @ctxt: the XPath context
2652 xmlXPathCacheConvertString(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
2656 return(xmlXPathCacheNewCString(ctxt, ""));
2683 xmlXPathReleaseObject(ctxt, val);
2685 return(xmlXPathCacheNewCString(ctxt, ""));
2686 return(xmlXPathCacheWrapString(ctxt, res));
2691 * @ctxt: the XPath context
2700 xmlXPathCacheObjectCopy(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val)
2705 if (XP_HAS_CACHE(ctxt)) {
2708 return(xmlXPathCacheWrapNodeSet(ctxt,
2711 return(xmlXPathCacheNewString(ctxt, val->stringval));
2713 return(xmlXPathCacheNewBoolean(ctxt, val->boolval));
2715 return(xmlXPathCacheNewFloat(ctxt, val->floatval));
2725 * @ctxt: the XPath context
2735 xmlXPathCacheConvertBoolean(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
2739 return(xmlXPathCacheNewBoolean(ctxt, 0));
2742 ret = xmlXPathCacheNewBoolean(ctxt, xmlXPathCastToBoolean(val));
2743 xmlXPathReleaseObject(ctxt, val);
2749 * @ctxt: the XPath context
2759 xmlXPathCacheConvertNumber(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
2763 return(xmlXPathCacheNewFloat(ctxt, 0.0));
2766 ret = xmlXPathCacheNewFloat(ctxt, xmlXPathCastToNumber(val));
2767 xmlXPathReleaseObject(ctxt, val);
2779 * @ctxt: an XPath parser context
2786 xmlXPathSetFrame(xmlXPathParserContextPtr ctxt) {
2789 if (ctxt == NULL)
2791 ret = ctxt->valueFrame;
2792 ctxt->valueFrame = ctxt->valueNr;
2798 * @ctxt: an XPath parser context
2804 xmlXPathPopFrame(xmlXPathParserContextPtr ctxt, int frame) {
2805 if (ctxt == NULL)
2807 if (ctxt->valueNr < ctxt->valueFrame) {
2808 xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_STACK_ERROR);
2810 ctxt->valueFrame = frame;
2815 * @ctxt: an XPath evaluation context
2822 valuePop(xmlXPathParserContextPtr ctxt)
2826 if ((ctxt == NULL) || (ctxt->valueNr <= 0))
2829 if (ctxt->valueNr <= ctxt->valueFrame) {
2830 xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_STACK_ERROR);
2834 ctxt->valueNr--;
2835 if (ctxt->valueNr > 0)
2836 ctxt->value = ctxt->valueTab[ctxt->valueNr - 1];
2838 ctxt->value = NULL;
2839 ret = ctxt->valueTab[ctxt->valueNr];
2840 ctxt->valueTab[ctxt->valueNr] = NULL;
2845 * @ctxt: an XPath evaluation context
2853 valuePush(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value)
2855 if ((ctxt == NULL) || (value == NULL)) return(-1);
2856 if (ctxt->valueNr >= ctxt->valueMax) {
2859 if (ctxt->valueMax >= XPATH_MAX_STACK_DEPTH) {
2861 ctxt->error = XPATH_MEMORY_ERROR;
2864 tmp = (xmlXPathObjectPtr *) xmlRealloc(ctxt->valueTab,
2865 2 * ctxt->valueMax *
2866 sizeof(ctxt->valueTab[0]));
2869 ctxt->error = XPATH_MEMORY_ERROR;
2872 ctxt->valueMax *= 2;
2873 ctxt->valueTab = tmp;
2875 ctxt->valueTab[ctxt->valueNr] = value;
2876 ctxt->value = value;
2877 return (ctxt->valueNr++);
2882 * @ctxt: an XPath parser context
2890 xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt) {
2894 obj = valuePop(ctxt);
2896 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
2903 xmlXPathReleaseObject(ctxt->context, obj);
2909 * @ctxt: an XPath parser context
2917 xmlXPathPopNumber (xmlXPathParserContextPtr ctxt) {
2921 obj = valuePop(ctxt);
2923 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
2930 xmlXPathReleaseObject(ctxt->context, obj);
2936 * @ctxt: an XPath parser context
2944 xmlXPathPopString (xmlXPathParserContextPtr ctxt) {
2948 obj = valuePop(ctxt);
2950 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
2957 xmlXPathReleaseObject(ctxt->context, obj);
2963 * @ctxt: an XPath parser context
2971 xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt) {
2975 if (ctxt == NULL) return(NULL);
2976 if (ctxt->value == NULL) {
2977 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
2980 if (!xmlXPathStackIsNodeSet(ctxt)) {
2981 xmlXPathSetTypeError(ctxt);
2984 obj = valuePop(ctxt);
2992 xmlXPathReleaseObject(ctxt->context, obj);
2998 * @ctxt: an XPath parser context
3006 xmlXPathPopExternal (xmlXPathParserContextPtr ctxt) {
3010 if ((ctxt == NULL) || (ctxt->value == NULL)) {
3011 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
3014 if (ctxt->value->type != XPATH_USERS) {
3015 xmlXPathSetTypeError(ctxt);
3018 obj = valuePop(ctxt);
3021 xmlXPathReleaseObject(ctxt->context, obj);
3048 #define CUR (*ctxt->cur)
3049 #define SKIP(val) ctxt->cur += (val)
3050 #define NXT(val) ctxt->cur[(val)]
3051 #define CUR_PTR ctxt->cur
3052 #define CUR_CHAR(l) xmlXPathCurrentChar(ctxt, &l)
3058 #define NEXTL(l) ctxt->cur += l
3061 while (IS_BLANK_CH(*(ctxt->cur))) NEXT
3063 #define CURRENT (*ctxt->cur)
3064 #define NEXT ((*ctxt->cur) ? ctxt->cur++: ctxt->cur)
4836 * @ctxt: the XPath context
4845 xmlXPathRegisterFunc(xmlXPathContextPtr ctxt, const xmlChar *name,
4847 return(xmlXPathRegisterFuncNS(ctxt, name, NULL, f));
4852 * @ctxt: the XPath context
4862 xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name,
4864 if (ctxt == NULL)
4869 if (ctxt->funcHash == NULL)
4870 ctxt->funcHash = xmlHashCreate(0);
4871 if (ctxt->funcHash == NULL)
4874 return(xmlHashRemoveEntry2(ctxt->funcHash, name, ns_uri, NULL));
4875 return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, XML_CAST_FPTR(f)));
4880 * @ctxt: the XPath context
4887 xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
4890 if (ctxt == NULL)
4892 ctxt->funcLookupFunc = f;
4893 ctxt->funcLookupData = funcCtxt;
4898 * @ctxt: the XPath context
4907 xmlXPathFunctionLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
4908 if (ctxt == NULL)
4911 if (ctxt->funcLookupFunc != NULL) {
4915 f = ctxt->funcLookupFunc;
4916 ret = f(ctxt->funcLookupData, name, NULL);
4920 return(xmlXPathFunctionLookupNS(ctxt, name, NULL));
4925 * @ctxt: the XPath context
4935 xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
4939 if (ctxt == NULL)
4944 if (ctxt->funcLookupFunc != NULL) {
4947 f = ctxt->funcLookupFunc;
4948 ret = f(ctxt->funcLookupData, name, ns_uri);
4953 if (ctxt->funcHash == NULL)
4956 XML_CAST_FPTR(ret) = xmlHashLookup2(ctxt->funcHash, name, ns_uri);
4962 * @ctxt: the XPath context
4967 xmlXPathRegisteredFuncsCleanup(xmlXPathContextPtr ctxt) {
4968 if (ctxt == NULL)
4971 xmlHashFree(ctxt->funcHash, NULL);
4972 ctxt->funcHash = NULL;
4983 * @ctxt
4993 xmlXPathRegisterVariable(xmlXPathContextPtr ctxt, const xmlChar *name,
4995 return(xmlXPathRegisterVariableNS(ctxt, name, NULL, value));
5000 * @ctxt: the XPath context
5011 xmlXPathRegisterVariableNS(xmlXPathContextPtr ctxt, const xmlChar *name,
5014 if (ctxt == NULL)
5019 if (ctxt->varHash == NULL)
5020 ctxt->varHash = xmlHashCreate(0);
5021 if (ctxt->varHash == NULL)
5024 return(xmlHashRemoveEntry2(ctxt->varHash, name, ns_uri,
5026 return(xmlHashUpdateEntry2(ctxt->varHash, name, ns_uri,
5033 * @ctxt: the XPath context
5040 xmlXPathRegisterVariableLookup(xmlXPathContextPtr ctxt,
5042 if (ctxt == NULL)
5044 ctxt->varLookupFunc = f;
5045 ctxt->varLookupData = data;
5050 * @ctxt: the XPath context
5059 xmlXPathVariableLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
5060 if (ctxt == NULL)
5063 if (ctxt->varLookupFunc != NULL) {
5066 ret = ((xmlXPathVariableLookupFunc)ctxt->varLookupFunc)
5067 (ctxt->varLookupData, name, NULL);
5070 return(xmlXPathVariableLookupNS(ctxt, name, NULL));
5075 * @ctxt: the XPath context
5085 xmlXPathVariableLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
5087 if (ctxt == NULL)
5090 if (ctxt->varLookupFunc != NULL) {
5093 ret = ((xmlXPathVariableLookupFunc)ctxt->varLookupFunc)
5094 (ctxt->varLookupData, name, ns_uri);
5098 if (ctxt->varHash == NULL)
5103 return(xmlXPathCacheObjectCopy(ctxt, (xmlXPathObjectPtr)
5104 xmlHashLookup2(ctxt->varHash, name, ns_uri)));
5109 * @ctxt: the XPath context
5114 xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt) {
5115 if (ctxt == NULL)
5118 xmlHashFree(ctxt->varHash, (xmlHashDeallocator)xmlXPathFreeObject);
5119 ctxt->varHash = NULL;
5124 * @ctxt: the XPath context
5134 xmlXPathRegisterNs(xmlXPathContextPtr ctxt, const xmlChar *prefix,
5136 if (ctxt == NULL)
5143 if (ctxt->nsHash == NULL)
5144 ctxt->nsHash = xmlHashCreate(10);
5145 if (ctxt->nsHash == NULL)
5148 return(xmlHashRemoveEntry(ctxt->nsHash, prefix,
5150 return(xmlHashUpdateEntry(ctxt->nsHash, prefix, (void *) xmlStrdup(ns_uri),
5156 * @ctxt: the XPath context
5165 xmlXPathNsLookup(xmlXPathContextPtr ctxt, const xmlChar *prefix) {
5166 if (ctxt == NULL)
5176 if (ctxt->namespaces != NULL) {
5179 for (i = 0;i < ctxt->nsNr;i++) {
5180 if ((ctxt->namespaces[i] != NULL) &&
5181 (xmlStrEqual(ctxt->namespaces[i]->prefix, prefix)))
5182 return(ctxt->namespaces[i]->href);
5186 return((const xmlChar *) xmlHashLookup(ctxt->nsHash, prefix));
5191 * @ctxt: the XPath context
5196 xmlXPathRegisteredNsCleanup(xmlXPathContextPtr ctxt) {
5197 if (ctxt == NULL)
5200 xmlHashFree(ctxt->nsHash, (xmlHashDeallocator)xmlFree);
5201 ctxt->nsHash = NULL;
5522 xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj)
5532 if ((ctxt == NULL) || (ctxt->cache == NULL)) {
5536 (xmlXPathContextCachePtr) ctxt->cache;
5606 xmlXPathDebugObjUsageReleased(ctxt, obj->type);
6155 * @ctxt: the context to free
6160 xmlXPathFreeContext(xmlXPathContextPtr ctxt) {
6161 if (ctxt == NULL) return;
6163 if (ctxt->cache != NULL)
6164 xmlXPathFreeCache((xmlXPathContextCachePtr) ctxt->cache);
6165 xmlXPathRegisteredNsCleanup(ctxt);
6166 xmlXPathRegisteredFuncsCleanup(ctxt);
6167 xmlXPathRegisteredVariablesCleanup(ctxt);
6168 xmlResetError(&ctxt->lastError);
6169 xmlFree(ctxt);
6178 #define CHECK_CTXT(ctxt) \
6179 if (ctxt == NULL) { \
6189 #define CHECK_CTXT_NEG(ctxt) \
6190 if (ctxt == NULL) { \
6201 #define CHECK_CONTEXT(ctxt) \
6202 if ((ctxt == NULL) || (ctxt->doc == NULL) || \
6203 (ctxt->doc->children == NULL)) { \
6204 xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_INVALID_CTXT); \
6212 * @ctxt: the XPath context
6219 xmlXPathNewParserContext(const xmlChar *str, xmlXPathContextPtr ctxt) {
6224 xmlXPathErrMemory(ctxt, "creating parser context\n");
6229 ret->context = ctxt;
6237 if ((ctxt != NULL) && (ctxt->dict != NULL)) {
6238 ret->comp->dict = ctxt->dict;
6248 * @ctxt: the XPath context
6255 xmlXPathCompParserContext(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt) {
6260 xmlXPathErrMemory(ctxt, "creating evaluation context\n");
6270 xmlXPathErrMemory(ctxt, "creating evaluation context\n");
6278 ret->context = ctxt;
6286 * @ctxt: the context to free
6291 xmlXPathFreeParserContext(xmlXPathParserContextPtr ctxt) {
6292 if (ctxt->valueTab != NULL) {
6293 xmlFree(ctxt->valueTab);
6295 if (ctxt->comp != NULL) {
6297 if (ctxt->comp->stream != NULL) {
6298 xmlFreePatternList(ctxt->comp->stream);
6299 ctxt->comp->stream = NULL;
6302 xmlXPathFreeCompExpr(ctxt->comp);
6304 xmlFree(ctxt);
6453 * @ctxt: the XPath Parser context
6474 xmlXPathCompareNodeSetFloat(xmlXPathParserContextPtr ctxt, int inf, int strict,
6482 xmlXPathReleaseObject(ctxt->context, arg);
6483 xmlXPathReleaseObject(ctxt->context, f);
6491 valuePush(ctxt,
6492 xmlXPathCacheNewString(ctxt->context, str2));
6494 xmlXPathNumberFunction(ctxt, 1);
6495 valuePush(ctxt, xmlXPathCacheObjectCopy(ctxt->context, f));
6496 ret = xmlXPathCompareValues(ctxt, inf, strict);
6502 xmlXPathReleaseObject(ctxt->context, arg);
6503 xmlXPathReleaseObject(ctxt->context, f);
6509 * @ctxt: the XPath Parser context
6529 xmlXPathCompareNodeSetString(xmlXPathParserContextPtr ctxt, int inf, int strict,
6537 xmlXPathReleaseObject(ctxt->context, arg);
6538 xmlXPathReleaseObject(ctxt->context, s);
6546 valuePush(ctxt,
6547 xmlXPathCacheNewString(ctxt->context, str2));
6549 valuePush(ctxt, xmlXPathCacheObjectCopy(ctxt->context, s));
6550 ret = xmlXPathCompareValues(ctxt, inf, strict);
6556 xmlXPathReleaseObject(ctxt->context, arg);
6557 xmlXPathReleaseObject(ctxt->context, s);
6665 * @ctxt: the XPath Parser context
6685 xmlXPathCompareNodeSetValue(xmlXPathParserContextPtr ctxt, int inf, int strict,
6693 return(xmlXPathCompareNodeSetFloat(ctxt, inf, strict, arg, val));
6698 return(xmlXPathCompareNodeSetString(ctxt, inf, strict, arg, val));
6700 valuePush(ctxt, arg);
6701 xmlXPathBooleanFunction(ctxt, 1);
6702 valuePush(ctxt, val);
6703 return(xmlXPathCompareValues(ctxt, inf, strict));
6784 xmlXPathEqualNodeSetFloat(xmlXPathParserContextPtr ctxt,
6801 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, str2));
6803 xmlXPathNumberFunction(ctxt, 1);
6804 val = valuePop(ctxt);
6806 xmlXPathReleaseObject(ctxt->context, val);
6945 xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
7010 valuePush(ctxt, arg2);
7011 xmlXPathNumberFunction(ctxt, 1);
7012 arg2 = valuePop(ctxt);
7073 valuePush(ctxt, arg1);
7074 xmlXPathNumberFunction(ctxt, 1);
7075 arg1 = valuePop(ctxt);
7125 xmlXPathReleaseObject(ctxt->context, arg1);
7126 xmlXPathReleaseObject(ctxt->context, arg2);
7132 * @ctxt: the XPath Parser context
7139 xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
7143 if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
7144 arg2 = valuePop(ctxt);
7145 arg1 = valuePop(ctxt);
7148 xmlXPathReleaseObject(ctxt->context, arg1);
7150 xmlXPathReleaseObject(ctxt->context, arg2);
7195 ret = xmlXPathEqualNodeSetFloat(ctxt, arg1, arg2->floatval, 0);
7207 xmlXPathReleaseObject(ctxt->context, arg1);
7208 xmlXPathReleaseObject(ctxt->context, arg2);
7212 return (xmlXPathEqualValuesCommon(ctxt, arg1, arg2));
7217 * @ctxt: the XPath Parser context
7224 xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt) {
7228 if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
7229 arg2 = valuePop(ctxt);
7230 arg1 = valuePop(ctxt);
7233 xmlXPathReleaseObject(ctxt->context, arg1);
7235 xmlXPathReleaseObject(ctxt->context, arg2);
7244 xmlXPathReleaseObject(ctxt->context, arg1);
7280 ret = xmlXPathEqualNodeSetFloat(ctxt, arg1, arg2->floatval, 1);
7292 xmlXPathReleaseObject(ctxt->context, arg1);
7293 xmlXPathReleaseObject(ctxt->context, arg2);
7297 return (!xmlXPathEqualValuesCommon(ctxt, arg1, arg2));
7302 * @ctxt: the XPath Parser context
7325 xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict) {
7329 if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
7330 arg2 = valuePop(ctxt);
7331 arg1 = valuePop(ctxt);
7334 xmlXPathReleaseObject(ctxt->context, arg1);
7336 xmlXPathReleaseObject(ctxt->context, arg2);
7352 ret = xmlXPathCompareNodeSetValue(ctxt, inf, strict,
7355 ret = xmlXPathCompareNodeSetValue(ctxt, !inf, strict,
7363 valuePush(ctxt, arg1);
7364 xmlXPathNumberFunction(ctxt, 1);
7365 arg1 = valuePop(ctxt);
7373 valuePush(ctxt, arg2);
7374 xmlXPathNumberFunction(ctxt, 1);
7375 arg2 = valuePop(ctxt);
7378 xmlXPathReleaseObject(ctxt->context, arg1);
7379 xmlXPathReleaseObject(ctxt->context, arg2);
7431 xmlXPathReleaseObject(ctxt->context, arg1);
7432 xmlXPathReleaseObject(ctxt->context, arg2);
7438 * @ctxt: the XPath Parser context
7445 xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt) {
7446 if ((ctxt == NULL) || (ctxt->context == NULL)) return;
7449 if (xmlXPathIsNaN(ctxt->value->floatval))
7450 ctxt->value->floatval=xmlXPathNAN;
7451 else if (xmlXPathIsInf(ctxt->value->floatval) == 1)
7452 ctxt->value->floatval=xmlXPathNINF;
7453 else if (xmlXPathIsInf(ctxt->value->floatval) == -1)
7454 ctxt->value->floatval=xmlXPathPINF;
7455 else if (ctxt->value->floatval == 0) {
7456 if (xmlXPathGetSign(ctxt->value->floatval) == 0)
7457 ctxt->value->floatval = xmlXPathNZERO;
7459 ctxt->value->floatval = 0;
7462 ctxt->value->floatval = - ctxt->value->floatval;
7467 * @ctxt: the XPath Parser context
7474 xmlXPathAddValues(xmlXPathParserContextPtr ctxt) {
7478 arg = valuePop(ctxt);
7482 xmlXPathReleaseObject(ctxt->context, arg);
7485 ctxt->value->floatval += val;
7490 * @ctxt: the XPath Parser context
7497 xmlXPathSubValues(xmlXPathParserContextPtr ctxt) {
7501 arg = valuePop(ctxt);
7505 xmlXPathReleaseObject(ctxt->context, arg);
7508 ctxt->value->floatval -= val;
7513 * @ctxt: the XPath Parser context
7520 xmlXPathMultValues(xmlXPathParserContextPtr ctxt) {
7524 arg = valuePop(ctxt);
7528 xmlXPathReleaseObject(ctxt->context, arg);
7531 ctxt->value->floatval *= val;
7536 * @ctxt: the XPath Parser context
7543 xmlXPathDivValues(xmlXPathParserContextPtr ctxt) {
7547 arg = valuePop(ctxt);
7551 xmlXPathReleaseObject(ctxt->context, arg);
7554 if (xmlXPathIsNaN(val) || xmlXPathIsNaN(ctxt->value->floatval))
7555 ctxt->value->floatval = xmlXPathNAN;
7557 if (ctxt->value->floatval == 0)
7558 ctxt->value->floatval = xmlXPathNAN;
7559 else if (ctxt->value->floatval > 0)
7560 ctxt->value->floatval = xmlXPathNINF;
7561 else if (ctxt->value->floatval < 0)
7562 ctxt->value->floatval = xmlXPathPINF;
7565 if (ctxt->value->floatval == 0)
7566 ctxt->value->floatval = xmlXPathNAN;
7567 else if (ctxt->value->floatval > 0)
7568 ctxt->value->floatval = xmlXPathPINF;
7569 else if (ctxt->value->floatval < 0)
7570 ctxt->value->floatval = xmlXPathNINF;
7572 ctxt->value->floatval /= val;
7577 * @ctxt: the XPath Parser context
7584 xmlXPathModValues(xmlXPathParserContextPtr ctxt) {
7588 arg = valuePop(ctxt);
7592 xmlXPathReleaseObject(ctxt->context, arg);
7595 arg1 = ctxt->value->floatval;
7597 ctxt->value->floatval = xmlXPathNAN;
7599 ctxt->value->floatval = fmod(arg1, arg2);
7615 (xmlXPathParserContextPtr ctxt, xmlNodePtr cur);
7637 * @ctxt: the XPath Parser context
7646 xmlXPathNextSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7647 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7649 return(ctxt->context->node);
7655 * @ctxt: the XPath Parser context
7664 xmlXPathNextChild(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7665 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7667 if (ctxt->context->node == NULL) return(NULL);
7668 switch (ctxt->context->node->type) {
7678 return(ctxt->context->node->children);
7686 return(((xmlDocPtr) ctxt->context->node)->children);
7706 * @ctxt: the XPath Parser context
7715 xmlXPathNextChildElement(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7716 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7718 cur = ctxt->context->node;
7782 * @ctxt: the XPath Parser context
7859 * @ctxt: the XPath Parser context
7869 xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7870 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7872 if (ctxt->context->node == NULL)
7874 if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
7875 (ctxt->context->node->type == XML_NAMESPACE_DECL))
7878 if (ctxt->context->node == (xmlNodePtr) ctxt->context->doc)
7879 return(ctxt->context->doc->children);
7880 return(ctxt->context->node->children);
7899 if (cur == ctxt->context->node) return(NULL);
7911 if (cur == ctxt->context->node) return(NULL);
7922 * @ctxt: the XPath Parser context
7934 xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7935 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7937 return(ctxt->context->node);
7939 if (ctxt->context->node == NULL)
7941 if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
7942 (ctxt->context->node->type == XML_NAMESPACE_DECL))
7945 return(xmlXPathNextDescendant(ctxt, cur));
7950 * @ctxt: the XPath Parser context
7959 xmlXPathNextParent(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7960 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7967 if (ctxt->context->node == NULL) return(NULL);
7968 switch (ctxt->context->node->type) {
7983 if (ctxt->context->node->parent == NULL)
7984 return((xmlNodePtr) ctxt->context->doc);
7985 if ((ctxt->context->node->parent->type == XML_ELEMENT_NODE) &&
7986 ((ctxt->context->node->parent->name[0] == ' ') ||
7987 (xmlStrEqual(ctxt->context->node->parent->name,
7990 return(ctxt->context->node->parent);
7992 xmlAttrPtr att = (xmlAttrPtr) ctxt->context->node;
8005 xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
8019 * @ctxt: the XPath Parser context
8032 xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8033 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8040 if (ctxt->context->node == NULL) return(NULL);
8041 switch (ctxt->context->node->type) {
8056 if (ctxt->context->node->parent == NULL)
8057 return((xmlNodePtr) ctxt->context->doc);
8058 if ((ctxt->context->node->parent->type == XML_ELEMENT_NODE) &&
8059 ((ctxt->context->node->parent->name[0] == ' ') ||
8060 (xmlStrEqual(ctxt->context->node->parent->name,
8063 return(ctxt->context->node->parent);
8065 xmlAttrPtr tmp = (xmlAttrPtr) ctxt->context->node;
8078 xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
8089 if (cur == ctxt->context->doc->children)
8090 return((xmlNodePtr) ctxt->context->doc);
8091 if (cur == (xmlNodePtr) ctxt->context->doc)
8117 xmlAttrPtr att = (xmlAttrPtr) ctxt->context->node;
8122 xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
8144 * @ctxt: the XPath Parser context
8156 xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8157 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8159 return(ctxt->context->node);
8160 return(xmlXPathNextAncestor(ctxt, cur));
8165 * @ctxt: the XPath Parser context
8175 xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8176 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8177 if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
8178 (ctxt->context->node->type == XML_NAMESPACE_DECL))
8180 if (cur == (xmlNodePtr) ctxt->context->doc)
8183 return(ctxt->context->node->next);
8189 * @ctxt: the XPath Parser context
8200 xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8201 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8202 if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
8203 (ctxt->context->node->type == XML_NAMESPACE_DECL))
8205 if (cur == (xmlNodePtr) ctxt->context->doc)
8208 return(ctxt->context->node->prev);
8212 return(ctxt->context->node->prev);
8219 * @ctxt: the XPath Parser context
8231 xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8232 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8238 cur = ctxt->context->node;
8249 if (cur == (xmlNodePtr) ctxt->context->doc) return(NULL);
8286 * @ctxt: the XPath Parser context
8298 xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur)
8300 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8302 cur = ctxt->context->node;
8321 if (cur == ctxt->context->doc->children)
8323 } while (xmlXPathIsAncestor(cur, ctxt->context->node));
8329 * @ctxt: the XPath Parser context
8338 * state kept in the parser context: ctxt->ancestor.
8343 xmlXPathNextPrecedingInternal(xmlXPathParserContextPtr ctxt,
8346 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8348 cur = ctxt->context->node;
8353 ctxt->ancestor = cur->parent;
8363 if (cur == ctxt->context->doc->children)
8365 if (cur != ctxt->ancestor)
8367 ctxt->ancestor = cur->parent;
8377 * @ctxt: the XPath Parser context
8390 xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8391 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8392 if (ctxt->context->node->type != XML_ELEMENT_NODE) return(NULL);
8394 if (ctxt->context->tmpNsList != NULL)
8395 xmlFree(ctxt->context->tmpNsList);
8396 ctxt->context->tmpNsList =
8397 xmlGetNsList(ctxt->context->doc, ctxt->context->node);
8398 ctxt->context->tmpNsNr = 0;
8399 if (ctxt->context->tmpNsList != NULL) {
8400 while (ctxt->context->tmpNsList[ctxt->context->tmpNsNr] != NULL) {
8401 ctxt->context->tmpNsNr++;
8406 if (ctxt->context->tmpNsNr > 0) {
8407 return (xmlNodePtr)ctxt->context->tmpNsList[--ctxt->context->tmpNsNr];
8409 if (ctxt->context->tmpNsList != NULL)
8410 xmlFree(ctxt->context->tmpNsList);
8411 ctxt->context->tmpNsList = NULL;
8418 * @ctxt: the XPath Parser context
8427 xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8428 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8429 if (ctxt->context->node == NULL)
8431 if (ctxt->context->node->type != XML_ELEMENT_NODE)
8434 if (ctxt->context->node == (xmlNodePtr) ctxt->context->doc)
8436 return((xmlNodePtr)ctxt->context->node->properties);
8458 * @ctxt: the XPath Parser context
8463 xmlXPathRoot(xmlXPathParserContextPtr ctxt) {
8464 if ((ctxt == NULL) || (ctxt->context == NULL))
8466 ctxt->context->node = (xmlNodePtr) ctxt->context->doc;
8467 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8468 ctxt->context->node));
8481 * @ctxt: the XPath Parser context
8489 xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8491 if (ctxt->context->contextSize >= 0) {
8492 valuePush(ctxt,
8493 xmlXPathCacheNewFloat(ctxt->context,
8494 (double) ctxt->context->contextSize));
8497 "last() : %d\n", ctxt->context->contextSize);
8506 * @ctxt: the XPath Parser context
8516 xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8518 if (ctxt->context->proximityPosition >= 0) {
8519 valuePush(ctxt,
8520 xmlXPathCacheNewFloat(ctxt->context,
8521 (double) ctxt->context->proximityPosition));
8524 ctxt->context->proximityPosition);
8533 * @ctxt: the XPath Parser context
8540 xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8544 if ((ctxt->value == NULL) ||
8545 ((ctxt->value->type != XPATH_NODESET) &&
8546 (ctxt->value->type != XPATH_XSLT_TREE)))
8548 cur = valuePop(ctxt);
8551 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0));
8553 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context,
8558 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0));
8571 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) i));
8574 xmlXPathReleaseObject(ctxt->context, cur);
8636 * @ctxt: the XPath Parser context
8653 xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8659 obj = valuePop(ctxt);
8669 * ctxt, so the object is in a corrupt state.
8676 ns = xmlXPathGetElementsByIds(ctxt->context->doc, tokens);
8683 xmlXPathReleaseObject(ctxt->context, obj);
8684 valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, ret));
8687 obj = xmlXPathCacheConvertString(ctxt->context, obj);
8688 ret = xmlXPathGetElementsByIds(ctxt->context->doc, obj->stringval);
8689 valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, ret));
8690 xmlXPathReleaseObject(ctxt->context, obj);
8696 * @ctxt: the XPath Parser context
8708 xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8711 if (ctxt == NULL) return;
8714 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8715 ctxt->context->node));
8720 if ((ctxt->value == NULL) ||
8721 ((ctxt->value->type != XPATH_NODESET) &&
8722 (ctxt->value->type != XPATH_XSLT_TREE)))
8724 cur = valuePop(ctxt);
8727 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8735 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8737 valuePush(ctxt,
8738 xmlXPathCacheNewString(ctxt->context,
8742 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
8746 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8749 xmlXPathReleaseObject(ctxt->context, cur);
8754 * @ctxt: the XPath Parser context
8767 xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8770 if (ctxt == NULL) return;
8773 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8774 ctxt->context->node));
8778 if ((ctxt->value == NULL) ||
8779 ((ctxt->value->type != XPATH_NODESET) &&
8780 (ctxt->value->type != XPATH_XSLT_TREE)))
8782 cur = valuePop(ctxt);
8785 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8792 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8794 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
8798 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8801 xmlXPathReleaseObject(ctxt->context, cur);
8806 * @ctxt: the XPath Parser context
8827 xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs)
8832 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8833 ctxt->context->node));
8838 if ((ctxt->value == NULL) ||
8839 ((ctxt->value->type != XPATH_NODESET) &&
8840 (ctxt->value->type != XPATH_XSLT_TREE)))
8842 cur = valuePop(ctxt);
8845 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8853 valuePush(ctxt,
8854 xmlXPathCacheNewCString(ctxt->context, ""));
8857 valuePush(ctxt,
8858 xmlXPathCacheNewString(ctxt->context,
8871 valuePush(ctxt, xmlXPathCacheWrapString(
8872 ctxt->context, fullname));
8876 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8878 xmlXPathLocalNameFunction(ctxt, 1);
8881 xmlXPathReleaseObject(ctxt->context, cur);
8887 * @ctxt: the XPath Parser context
8922 xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8925 if (ctxt == NULL) return;
8927 valuePush(ctxt,
8928 xmlXPathCacheWrapString(ctxt->context,
8929 xmlXPathCastNodeToString(ctxt->context->node)));
8934 cur = valuePop(ctxt);
8936 valuePush(ctxt, xmlXPathCacheConvertString(ctxt->context, cur));
8941 * @ctxt: the XPath Parser context
8952 xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8956 if ((ctxt == NULL) || (ctxt->context == NULL))
8958 if (ctxt->context->node == NULL) {
8959 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, 0));
8963 content = xmlXPathCastNodeToString(ctxt->context->node);
8964 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context,
8973 cur = valuePop(ctxt);
8974 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context,
8976 xmlXPathReleaseObject(ctxt->context, cur);
8981 * @ctxt: the XPath Parser context
8989 xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8993 if (ctxt == NULL) return;
8999 cur = valuePop(ctxt);
9001 xmlXPathReleaseObject(ctxt->context, cur);
9008 newobj = valuePop(ctxt);
9010 xmlXPathReleaseObject(ctxt->context, newobj);
9011 xmlXPathReleaseObject(ctxt->context, cur);
9017 xmlXPathReleaseObject(ctxt->context, newobj);
9020 valuePush(ctxt, cur);
9025 * @ctxt: the XPath Parser context
9034 xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9040 needle = valuePop(ctxt);
9042 hay = valuePop(ctxt);
9045 xmlXPathReleaseObject(ctxt->context, hay);
9046 xmlXPathReleaseObject(ctxt->context, needle);
9050 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 1));
9052 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 0));
9053 xmlXPathReleaseObject(ctxt->context, hay);
9054 xmlXPathReleaseObject(ctxt->context, needle);
9059 * @ctxt: the XPath Parser context
9068 xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9075 needle = valuePop(ctxt);
9077 hay = valuePop(ctxt);
9080 xmlXPathReleaseObject(ctxt->context, hay);
9081 xmlXPathReleaseObject(ctxt->context, needle);
9086 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 0));
9088 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 1));
9089 xmlXPathReleaseObject(ctxt->context, hay);
9090 xmlXPathReleaseObject(ctxt->context, needle);
9095 * @ctxt: the XPath Parser context
9122 xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9140 len = valuePop(ctxt);
9142 xmlXPathReleaseObject(ctxt->context, len);
9147 start = valuePop(ctxt);
9149 xmlXPathReleaseObject(ctxt->context, start);
9152 str = valuePop(ctxt);
9209 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
9211 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, ret));
9214 xmlXPathReleaseObject(ctxt->context, str);
9219 * @ctxt: the XPath Parser context
9231 xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9240 find = valuePop(ctxt);
9242 str = valuePop(ctxt);
9251 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
9255 xmlXPathReleaseObject(ctxt->context, str);
9256 xmlXPathReleaseObject(ctxt->context, find);
9261 * @ctxt: the XPath Parser context
9274 xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9283 find = valuePop(ctxt);
9285 str = valuePop(ctxt);
9295 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
9299 xmlXPathReleaseObject(ctxt->context, str);
9300 xmlXPathReleaseObject(ctxt->context, find);
9305 * @ctxt: the XPath Parser context
9318 xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9324 if (ctxt == NULL) return;
9327 valuePush(ctxt,
9328 xmlXPathCacheWrapString(ctxt->context,
9329 xmlXPathCastNodeToString(ctxt->context->node)));
9336 obj = valuePop(ctxt);
9360 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
9364 xmlXPathReleaseObject(ctxt->context, obj);
9369 * @ctxt: the XPath Parser context
9389 xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9402 to = valuePop(ctxt);
9404 from = valuePop(ctxt);
9406 str = valuePop(ctxt);
9445 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
9448 xmlXPathReleaseObject(ctxt->context, str);
9449 xmlXPathReleaseObject(ctxt->context, from);
9450 xmlXPathReleaseObject(ctxt->context, to);
9455 * @ctxt: the XPath Parser context
9467 xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9471 cur = valuePop(ctxt);
9473 cur = xmlXPathCacheConvertBoolean(ctxt->context, cur);
9474 valuePush(ctxt, cur);
9479 * @ctxt: the XPath Parser context
9488 xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9492 ctxt->value->boolval = ! ctxt->value->boolval;
9497 * @ctxt: the XPath Parser context
9504 xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9506 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 1));
9511 * @ctxt: the XPath Parser context
9518 xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9520 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 0));
9525 * @ctxt: the XPath Parser context
9545 xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9555 val = valuePop(ctxt);
9557 theLang = xmlNodeGetLang(ctxt->context->node);
9569 xmlXPathReleaseObject(ctxt->context, val);
9570 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, ret));
9575 * @ctxt: the XPath Parser context
9582 xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9586 if (ctxt == NULL) return;
9588 if (ctxt->context->node == NULL) {
9589 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, 0.0));
9591 xmlChar* content = xmlNodeGetContent(ctxt->context->node);
9594 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, res));
9601 cur = valuePop(ctxt);
9602 valuePush(ctxt, xmlXPathCacheConvertNumber(ctxt->context, cur));
9607 * @ctxt: the XPath Parser context
9616 xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9622 if ((ctxt->value == NULL) ||
9623 ((ctxt->value->type != XPATH_NODESET) &&
9624 (ctxt->value->type != XPATH_XSLT_TREE)))
9626 cur = valuePop(ctxt);
9633 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, res));
9634 xmlXPathReleaseObject(ctxt->context, cur);
9651 * @ctxt: the XPath Parser context
9660 xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9667 XTRUNC(f, ctxt->value->floatval);
9668 if (f != ctxt->value->floatval) {
9669 if (ctxt->value->floatval > 0)
9670 ctxt->value->floatval = f;
9672 ctxt->value->floatval = f - 1;
9678 * @ctxt: the XPath Parser context
9687 xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9695 ctxt->value->floatval = ceil(ctxt->value->floatval);
9697 XTRUNC(f, ctxt->value->floatval);
9698 if (f != ctxt->value->floatval) {
9699 if (ctxt->value->floatval > 0)
9700 ctxt->value->floatval = f + 1;
9702 if (ctxt->value->floatval < 0 && f == 0)
9703 ctxt->value->floatval = xmlXPathNZERO;
9705 ctxt->value->floatval = f;
9714 * @ctxt: the XPath Parser context
9724 xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9731 if ((xmlXPathIsNaN(ctxt->value->floatval)) ||
9732 (xmlXPathIsInf(ctxt->value->floatval) == 1) ||
9733 (xmlXPathIsInf(ctxt->value->floatval) == -1) ||
9734 (ctxt->value->floatval == 0.0))
9737 XTRUNC(f, ctxt->value->floatval);
9738 if (ctxt->value->floatval < 0) {
9739 if (ctxt->value->floatval < f - 0.5)
9740 ctxt->value->floatval = f - 1;
9742 ctxt->value->floatval = f;
9743 if (ctxt->value->floatval == 0)
9744 ctxt->value->floatval = xmlXPathNZERO;
9746 if (ctxt->value->floatval < f + 0.5)
9747 ctxt->value->floatval = f;
9749 ctxt->value->floatval = f + 1;
9763 static void xmlXPathCompileExpr(xmlXPathParserContextPtr ctxt, int sort);
9764 static void xmlXPathCompPredicate(xmlXPathParserContextPtr ctxt, int filter);
9765 static void xmlXPathCompLocationPath(xmlXPathParserContextPtr ctxt);
9766 static void xmlXPathCompRelativeLocationPath(xmlXPathParserContextPtr ctxt);
9767 static xmlChar * xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt,
9772 * @ctxt: the XPath parser context
9783 xmlXPathCurrentChar(xmlXPathParserContextPtr ctxt, int *len) {
9788 if (ctxt == NULL)
9790 cur = ctxt->cur;
9857 * @ctxt: the XPath Parser context
9870 xmlXPathParseNCName(xmlXPathParserContextPtr ctxt) {
9875 if ((ctxt == NULL) || (ctxt->cur == NULL)) return(NULL);
9879 in = ctxt->cur;
9893 count = in - ctxt->cur;
9896 ret = xmlStrndup(ctxt->cur, count);
9897 ctxt->cur = in;
9901 return(xmlXPathParseNameComplex(ctxt, 0));
9907 * @ctxt: the XPath Parser context
9923 xmlXPathParseQName(xmlXPathParserContextPtr ctxt, xmlChar **prefix) {
9927 ret = xmlXPathParseNCName(ctxt);
9931 ret = xmlXPathParseNCName(ctxt);
9938 * @ctxt: the XPath Parser context
9951 xmlXPathParseName(xmlXPathParserContextPtr ctxt) {
9956 if ((ctxt == NULL) || (ctxt->cur == NULL)) return(NULL);
9960 in = ctxt->cur;
9972 count = in - ctxt->cur;
9974 ctxt->cur = in;
9977 ret = xmlStrndup(ctxt->cur, count);
9978 ctxt->cur = in;
9982 return(xmlXPathParseNameComplex(ctxt, 1));
9986 xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {
10176 * @ctxt: the XPath Parser context
10186 xmlXPathCompNumber(xmlXPathParserContextPtr ctxt)
10259 xmlXPathCacheNewFloat(ctxt->context, ret), NULL);
10264 * @ctxt: the XPath Parser context
10274 xmlXPathParseLiteral(xmlXPathParserContextPtr ctxt) {
10308 * @ctxt: the XPath Parser context
10318 xmlXPathCompLiteral(xmlXPathParserContextPtr ctxt) {
10349 xmlXPathCacheNewString(ctxt->context, ret), NULL);
10355 * @ctxt: the XPath Parser context
10371 xmlXPathCompVariableReference(xmlXPathParserContextPtr ctxt) {
10380 name = xmlXPathParseQName(ctxt, &prefix);
10384 ctxt->comp->last = -1;
10388 if ((ctxt->context != NULL) && (ctxt->context->flags & XML_XPATH_NOVAR)) {
10424 * @ctxt: the XPath Parser context
10433 xmlXPathCompFunctionCall(xmlXPathParserContextPtr ctxt) {
10439 name = xmlXPathParseQName(ctxt, &prefix);
10468 ctxt->comp->last = -1;
10471 int op1 = ctxt->comp->last;
10472 ctxt->comp->last = -1;
10473 xmlXPathCompileExpr(ctxt, sort);
10474 if (ctxt->error != XPATH_EXPRESSION_OK) {
10479 PUSH_BINARY_EXPR(XPATH_OP_ARG, op1, ctxt->comp->last, 0, 0);
10497 * @ctxt: the XPath Parser context
10508 xmlXPathCompPrimaryExpr(xmlXPathParserContextPtr ctxt) {
10510 if (CUR == '$') xmlXPathCompVariableReference(ctxt);
10514 xmlXPathCompileExpr(ctxt, 1);
10522 xmlXPathCompNumber(ctxt);
10524 xmlXPathCompLiteral(ctxt);
10526 xmlXPathCompFunctionCall(ctxt);
10533 * @ctxt: the XPath Parser context
10547 xmlXPathCompFilterExpr(xmlXPathParserContextPtr ctxt) {
10548 xmlXPathCompPrimaryExpr(ctxt);
10553 xmlXPathCompPredicate(ctxt, 1);
10562 * @ctxt: the XPath Parser context
10578 xmlXPathScanName(xmlXPathParserContextPtr ctxt) {
10584 cur = ctxt->cur;
10603 ret = xmlStrndup(cur, ctxt->cur - cur);
10604 ctxt->cur = cur;
10610 * @ctxt: the XPath Parser context
10627 xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
10662 name = xmlXPathScanName(ctxt);
10748 xmlXPathCompLocationPath(ctxt);
10750 xmlXPathCompFilterExpr(ctxt);
10758 PUSH_UNARY_EXPR(XPATH_OP_RESET, ctxt->comp->last, 1, 0);
10760 xmlXPathCompRelativeLocationPath(ctxt);
10762 xmlXPathCompRelativeLocationPath(ctxt);
10770 * @ctxt: the XPath Parser context
10779 xmlXPathCompUnionExpr(xmlXPathParserContextPtr ctxt) {
10780 xmlXPathCompPathExpr(ctxt);
10784 int op1 = ctxt->comp->last;
10789 xmlXPathCompPathExpr(ctxt);
10791 PUSH_BINARY_EXPR(XPATH_OP_UNION, op1, ctxt->comp->last, 0, 0);
10799 * @ctxt: the XPath Parser context
10808 xmlXPathCompUnaryExpr(xmlXPathParserContextPtr ctxt) {
10820 xmlXPathCompUnionExpr(ctxt);
10824 PUSH_UNARY_EXPR(XPATH_OP_PLUS, ctxt->comp->last, 2, 0);
10826 PUSH_UNARY_EXPR(XPATH_OP_PLUS, ctxt->comp->last, 3, 0);
10832 * @ctxt: the XPath Parser context
10844 xmlXPathCompMultiplicativeExpr(xmlXPathParserContextPtr ctxt) {
10845 xmlXPathCompUnaryExpr(ctxt);
10852 int op1 = ctxt->comp->last;
10865 xmlXPathCompUnaryExpr(ctxt);
10867 PUSH_BINARY_EXPR(XPATH_OP_MULT, op1, ctxt->comp->last, op, 0);
10874 * @ctxt: the XPath Parser context
10884 xmlXPathCompAdditiveExpr(xmlXPathParserContextPtr ctxt) {
10886 xmlXPathCompMultiplicativeExpr(ctxt);
10891 int op1 = ctxt->comp->last;
10897 xmlXPathCompMultiplicativeExpr(ctxt);
10899 PUSH_BINARY_EXPR(XPATH_OP_PLUS, op1, ctxt->comp->last, plus, 0);
10906 * @ctxt: the XPath Parser context
10923 xmlXPathCompRelationalExpr(xmlXPathParserContextPtr ctxt) {
10924 xmlXPathCompAdditiveExpr(ctxt);
10932 int op1 = ctxt->comp->last;
10941 xmlXPathCompAdditiveExpr(ctxt);
10943 PUSH_BINARY_EXPR(XPATH_OP_CMP, op1, ctxt->comp->last, inf, strict);
10950 * @ctxt: the XPath Parser context
10965 xmlXPathCompEqualityExpr(xmlXPathParserContextPtr ctxt) {
10966 xmlXPathCompRelationalExpr(ctxt);
10971 int op1 = ctxt->comp->last;
10978 xmlXPathCompRelationalExpr(ctxt);
10980 PUSH_BINARY_EXPR(XPATH_OP_EQUAL, op1, ctxt->comp->last, eq, 0);
10987 * @ctxt: the XPath Parser context
10996 xmlXPathCompAndExpr(xmlXPathParserContextPtr ctxt) {
10997 xmlXPathCompEqualityExpr(ctxt);
11001 int op1 = ctxt->comp->last;
11004 xmlXPathCompEqualityExpr(ctxt);
11006 ctxt->comp->last, 0, 0);
11013 * @ctxt: the XPath Parser context
11022 xmlXPathCompileExpr(xmlXPathParserContextPtr ctxt, int sort) {
11023 xmlXPathCompAndExpr(ctxt);
11027 int op1 = ctxt->comp->last;
11030 xmlXPathCompAndExpr(ctxt);
11032 PUSH_BINARY_EXPR(XPATH_OP_OR, op1, ctxt->comp->last, 0, 0);
11035 if ((sort) && (ctxt->comp->steps[ctxt->comp->last].op != XPATH_OP_VALUE)) {
11042 PUSH_UNARY_EXPR(XPATH_OP_SORT, ctxt->comp->last , 0, 0);
11048 * @ctxt: the XPath Parser context
11057 xmlXPathCompPredicate(xmlXPathParserContextPtr ctxt, int filter) {
11058 int op1 = ctxt->comp->last;
11067 ctxt->comp->last = -1;
11078 xmlXPathCompileExpr(ctxt, 0);
11080 xmlXPathCompileExpr(ctxt, 1);
11088 PUSH_BINARY_EXPR(XPATH_OP_FILTER, op1, ctxt->comp->last, 0, 0);
11090 PUSH_BINARY_EXPR(XPATH_OP_PREDICATE, op1, ctxt->comp->last, 0, 0);
11098 * @ctxt: the XPath Parser context
11118 xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
11142 name = xmlXPathParseNCName(ctxt);
11179 name = xmlXPathParseLiteral(ctxt);
11205 *prefix = xmlXPathNsLookup(ctxt->context, name);
11224 name = xmlXPathParseNCName(ctxt);
11302 * @ctxt: the XPath Parser context
11333 xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
11360 if (ctxt->xptr) {
11361 name = xmlXPathParseNCName(ctxt);
11363 op2 = ctxt->comp->last;
11372 xmlXPathCompileExpr(ctxt, 1);
11373 /* PUSH_BINARY_EXPR(XPATH_OP_RANGETO, op2, ctxt->comp->last, 0, 0); */
11390 name = xmlXPathParseNCName(ctxt);
11414 if (ctxt->error != XPATH_EXPRESSION_OK) {
11419 name = xmlXPathCompNodeTest(ctxt, &test, &type, &prefix, name);
11423 if ((prefix != NULL) && (ctxt->context != NULL) &&
11424 (ctxt->context->flags & XML_XPATH_CHECKNS)) {
11425 if (xmlXPathNsLookup(ctxt->context, prefix) == NULL) {
11426 xmlXPathErr(ctxt, XPATH_UNDEF_PREFIX_ERROR);
11436 if (ctxt->value == NULL)
11438 else if (ctxt->value->nodesetval == NULL)
11441 xmlGenericErrorContextNodeSet(stdout, ctxt->value->nodesetval);
11447 op1 = ctxt->comp->last;
11448 ctxt->comp->last = -1;
11452 xmlXPathCompPredicate(ctxt, 0);
11460 PUSH_FULL_EXPR(XPATH_OP_COLLECT, op1, ctxt->comp->last, axis,
11466 if (ctxt->value == NULL)
11468 else if (ctxt->value->nodesetval == NULL)
11472 ctxt->value->nodesetval);
11478 * @ctxt: the XPath Parser context
11489 (xmlXPathParserContextPtr ctxt) {
11500 xmlXPathCompStep(ctxt);
11509 xmlXPathCompStep(ctxt);
11513 xmlXPathCompStep(ctxt);
11521 * @ctxt: the XPath Parser context
11541 xmlXPathCompLocationPath(xmlXPathParserContextPtr ctxt) {
11544 xmlXPathCompRelativeLocationPath(ctxt);
11552 xmlXPathCompRelativeLocationPath(ctxt);
11559 xmlXPathCompRelativeLocationPath(ctxt);
11573 xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op);
11663 xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt,
11670 xmlXPathCompExprPtr comp = ctxt->comp;
11679 contextSize = xmlXPathCompOpEvalPredicate(ctxt,
11686 xmlXPathContextPtr xpctxt = ctxt->context;
11728 exprOp = &ctxt->comp->steps[op->ch2];
11756 ctxt->error = XPATH_MEMORY_ERROR;
11761 valuePush(ctxt, contextObj);
11763 res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1);
11765 if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) {
11781 if (ctxt->value == contextObj) {
11787 valuePop(ctxt);
11799 if (ctxt->value == contextObj)
11800 valuePop(ctxt);
11805 xmlXPathReleaseObject(ctxt->context, exprRes);
11819 xmlXPathCompOpEvalPositionalPredicate(xmlXPathParserContextPtr ctxt,
11828 xmlXPathCompExprPtr comp = ctxt->comp;
11834 contextSize = xmlXPathCompOpEvalPredicate(ctxt,
11859 xmlXPathContextPtr xpctxt = ctxt->context;
11878 exprOp = &ctxt->comp->steps[op->ch2];
11908 ctxt->error = XPATH_MEMORY_ERROR;
11913 frame = xmlXPathSetFrame(ctxt);
11914 valuePush(ctxt, contextObj);
11915 res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1);
11916 tmp = valuePop(ctxt);
11917 xmlXPathPopFrame(ctxt, frame);
11919 if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) {
11926 tmp = valuePop(ctxt);
11931 valuePush(ctxt, tmp);
11973 xmlXPathReleaseObject(ctxt->context, exprRes);
11976 if (ctxt->value == contextObj) {
11982 valuePop(ctxt);
12000 if (ctxt->value == contextObj)
12001 valuePop(ctxt);
12005 xmlXPathReleaseObject(ctxt->context, exprRes);
12019 xmlXPathIsPositionalPredicate(xmlXPathParserContextPtr ctxt,
12043 exprOp = &ctxt->comp->steps[op->ch2];
12074 xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
12084 ctxt->error = XPATH_MEMORY_ERROR; \
12088 ctxt->error = XPATH_MEMORY_ERROR; \
12096 ctxt->error = XPATH_MEMORY_ERROR; \
12101 ctxt->error = XPATH_MEMORY_ERROR; \
12139 xmlXPathContextPtr xpctxt = ctxt->context;
12143 obj = valuePop(ctxt);
12250 valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, NULL));
12279 predOp = &ctxt->comp->steps[op->ch2];
12280 if (xmlXPathIsPositionalPredicate(ctxt, predOp, &maxPos)) {
12285 predOp = &ctxt->comp->steps[predOp->ch1];
12319 (ctxt->error == XPATH_EXPRESSION_OK)) {
12336 cur = next(ctxt, cur);
12528 } while ((cur != NULL) && (ctxt->error == XPATH_EXPRESSION_OK));
12569 if (ctxt->error != XPATH_EXPRESSION_OK)
12582 * (E.g. ctxt->value->type == XPATH_LOCATIONSET)
12606 newSize = xmlXPathCompOpEvalPositionalPredicate(ctxt,
12609 newSize = xmlXPathCompOpEvalPredicate(ctxt,
12612 if (ctxt->error != XPATH_EXPRESSION_OK) {
12668 ctxt->value->boolval = 1;
12669 ctxt->value->user = obj->user;
12692 valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, outSeq));
12716 xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
12721 * @ctxt: the XPath parser context with the compiled expression
12731 xmlXPathCompOpEvalFirst(xmlXPathParserContextPtr ctxt,
12739 comp = ctxt->comp;
12745 xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch1],
12748 if ((ctxt->value != NULL)
12749 && (ctxt->value->type == XPATH_NODESET)
12750 && (ctxt->value->nodesetval != NULL)
12751 && (ctxt->value->nodesetval->nodeNr >= 1)) {
12762 if (ctxt->value->nodesetval->nodeNr > 1)
12763 xmlXPathNodeSetSort(ctxt->value->nodesetval);
12764 ctxt->value->nodesetval->nodeTab[0];
12767 xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch2],
12771 arg2 = valuePop(ctxt);
12774 arg1 = valuePop(ctxt);
12778 valuePush(ctxt, arg1);
12779 xmlXPathReleaseObject(ctxt->context, arg2);
12785 xmlXPathRoot(ctxt);
12789 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12792 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12794 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
12795 ctxt->context->node));
12799 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12802 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12804 ctxt->context->node = NULL;
12810 total = xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12813 total += xmlXPathNodeCollectAndTest(ctxt, op, first, NULL, 0);
12817 valuePush(ctxt,
12818 xmlXPathCacheObjectCopy(ctxt->context,
12824 xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch1],
12827 if ((ctxt->value != NULL)
12828 && (ctxt->value->type == XPATH_NODESET)
12829 && (ctxt->value->nodesetval != NULL)
12830 && (ctxt->value->nodesetval->nodeNr > 1))
12831 xmlXPathNodeSetSort(ctxt->value->nodesetval);
12835 total += xmlXPathCompOpEvalFilterFirst(ctxt, op, first);
12839 return (xmlXPathCompOpEval(ctxt, op));
12845 * @ctxt: the XPath parser context with the compiled expression
12855 xmlXPathCompOpEvalLast(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op,
12867 comp = ctxt->comp;
12872 bakd = ctxt->context->doc;
12873 bak = ctxt->context->node;
12874 pp = ctxt->context->proximityPosition;
12875 cs = ctxt->context->contextSize;
12877 xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch1], last);
12879 if ((ctxt->value != NULL)
12880 && (ctxt->value->type == XPATH_NODESET)
12881 && (ctxt->value->nodesetval != NULL)
12882 && (ctxt->value->nodesetval->nodeNr >= 1)) {
12886 if (ctxt->value->nodesetval->nodeNr > 1)
12887 xmlXPathNodeSetSort(ctxt->value->nodesetval);
12889 ctxt->value->nodesetval->nodeTab[ctxt->value->
12893 ctxt->context->doc = bakd;
12894 ctxt->context->node = bak;
12895 ctxt->context->proximityPosition = pp;
12896 ctxt->context->contextSize = cs;
12898 xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch2], last);
12900 if ((ctxt->value != NULL)
12901 && (ctxt->value->type == XPATH_NODESET)
12902 && (ctxt->value->nodesetval != NULL)
12903 && (ctxt->value->nodesetval->nodeNr >= 1)) { /* TODO: NOP ? */
12906 arg2 = valuePop(ctxt);
12909 arg1 = valuePop(ctxt);
12913 valuePush(ctxt, arg1);
12914 xmlXPathReleaseObject(ctxt->context, arg2);
12920 xmlXPathRoot(ctxt);
12924 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12927 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12929 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
12930 ctxt->context->node));
12934 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12937 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12939 ctxt->context->node = NULL;
12945 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12948 total += xmlXPathNodeCollectAndTest(ctxt, op, NULL, last, 0);
12952 valuePush(ctxt,
12953 xmlXPathCacheObjectCopy(ctxt->context,
12959 xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch1],
12962 if ((ctxt->value != NULL)
12963 && (ctxt->value->type == XPATH_NODESET)
12964 && (ctxt->value->nodesetval != NULL)
12965 && (ctxt->value->nodesetval->nodeNr > 1))
12966 xmlXPathNodeSetSort(ctxt->value->nodesetval);
12969 return (xmlXPathCompOpEval(ctxt, op));
12975 xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
12988 comp = ctxt->comp;
13007 xmlXPathCompOpEvalLast(ctxt,
13015 if ((ctxt->value != NULL) &&
13016 (ctxt->value->type == XPATH_NODESET) &&
13017 (ctxt->value->nodesetval != NULL) &&
13018 (ctxt->value->nodesetval->nodeTab != NULL) &&
13019 (ctxt->value->nodesetval->nodeNr > 1)) {
13020 ctxt->value->nodesetval->nodeTab[0] =
13021 ctxt->value->nodesetval->nodeTab[ctxt->
13026 ctxt->value->nodesetval->nodeNr = 1;
13027 *first = *(ctxt->value->nodesetval->nodeTab);
13034 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13038 if (ctxt->value == NULL)
13042 oldnode = ctxt->context->node;
13046 if (ctxt->value->type == XPATH_LOCATIONSET) {
13057 obj = valuePop(ctxt);
13059 ctxt->context->node = NULL;
13062 ctxt->context->contextSize = 0;
13063 ctxt->context->proximityPosition = 0;
13065 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13066 res = valuePop(ctxt);
13068 xmlXPathReleaseObject(ctxt->context, res);
13070 valuePush(ctxt, obj);
13081 ctxt->context->node = oldlocset->locTab[i]->user;
13082 ctxt->context->contextSize = oldlocset->locNr;
13083 ctxt->context->proximityPosition = i + 1;
13085 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
13086 ctxt->context->node);
13089 ctxt->context->node) < 0) {
13090 ctxt->error = XPATH_MEMORY_ERROR;
13093 valuePush(ctxt, tmp);
13095 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13096 if (ctxt->error != XPATH_EXPRESSION_OK) {
13104 res = valuePop(ctxt);
13105 if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
13107 xmlXPathCacheObjectCopy(ctxt->context,
13114 xmlXPathReleaseObject(ctxt->context, res);
13116 if (ctxt->value == tmp) {
13117 valuePop(ctxt);
13126 ctxt->context->node = NULL;
13136 xmlXPathReleaseObject(ctxt->context, tmp);
13141 xmlXPathReleaseObject(ctxt->context, obj);
13142 ctxt->context->node = NULL;
13143 ctxt->context->contextSize = -1;
13144 ctxt->context->proximityPosition = -1;
13145 valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
13146 ctxt->context->node = oldnode;
13157 obj = valuePop(ctxt);
13160 oldnode = ctxt->context->node;
13161 oldDoc = ctxt->context->doc;
13162 ctxt->context->node = NULL;
13165 ctxt->context->contextSize = 0;
13166 ctxt->context->proximityPosition = 0;
13170 xmlXPathCompOpEval(ctxt,
13173 res = valuePop(ctxt);
13177 valuePush(ctxt, obj);
13178 ctxt->context->node = oldnode;
13196 ctxt->context->node = oldset->nodeTab[i];
13199 ctxt->context->doc = oldset->nodeTab[i]->doc;
13201 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
13202 ctxt->context->node);
13205 ctxt->context->node) < 0) {
13206 ctxt->error = XPATH_MEMORY_ERROR;
13209 valuePush(ctxt, tmp);
13210 ctxt->context->contextSize = oldset->nodeNr;
13211 ctxt->context->proximityPosition = i + 1;
13213 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13214 if (ctxt->error != XPATH_EXPRESSION_OK) {
13223 res = valuePop(ctxt);
13224 if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
13226 ctxt->error = XPATH_MEMORY_ERROR;
13232 xmlXPathReleaseObject(ctxt->context, res);
13234 if (ctxt->value == tmp) {
13235 valuePop(ctxt);
13244 ctxt->context->node = NULL;
13254 xmlXPathReleaseObject(ctxt->context, tmp);
13259 xmlXPathReleaseObject(ctxt->context, obj);
13260 ctxt->context->node = NULL;
13261 ctxt->context->contextSize = -1;
13262 ctxt->context->proximityPosition = -1;
13264 ctxt->context->doc = oldDoc;
13265 valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, newset));
13267 ctxt->context->node = oldnode;
13274 * @ctxt: the XPath parser context with the compiled expression
13281 xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
13293 comp = ctxt->comp;
13298 bakd = ctxt->context->doc;
13299 bak = ctxt->context->node;
13300 pp = ctxt->context->proximityPosition;
13301 cs = ctxt->context->contextSize;
13302 total += xmlXPathCompOpEval(ctxt
13304 xmlXPathBooleanFunction(ctxt, 1);
13305 if ((ctxt->value == NULL) || (ctxt->value->boolval == 0))
13307 arg2 = valuePop(ctxt);
13308 ctxt->context->doc = bakd;
13309 ctxt->context->node = bak;
13310 ctxt->context->proximityPosition = pp;
13311 ctxt->context->contextSize = cs;
13312 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13313 if (ctxt->error) {
13317 xmlXPathBooleanFunction(ctxt, 1);
13318 arg1 = valuePop(ctxt);
13320 valuePush(ctxt, arg1);
13321 xmlXPathReleaseObject(ctxt->context, arg2);
13324 bakd = ctxt->context->doc;
13325 bak = ctxt->context->node;
13326 pp = ctxt->context->proximityPosition;
13327 cs = ctxt->context->contextSize;
13328 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13330 xmlXPathBooleanFunction(ctxt, 1);
13331 if ((ctxt->value == NULL) || (ctxt->value->boolval == 1))
13333 arg2 = valuePop(ctxt);
13334 ctxt->context->doc = bakd;
13335 ctxt->context->node = bak;
13336 ctxt->context->proximityPosition = pp;
13337 ctxt->context->contextSize = cs;
13338 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13339 if (ctxt->error) {
13343 xmlXPathBooleanFunction(ctxt, 1);
13344 arg1 = valuePop(ctxt);
13346 valuePush(ctxt, arg1);
13347 xmlXPathReleaseObject(ctxt->context, arg2);
13350 bakd = ctxt->context->doc;
13351 bak = ctxt->context->node;
13352 pp = ctxt->context->proximityPosition;
13353 cs = ctxt->context->contextSize;
13354 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13356 ctxt->context->doc = bakd;
13357 ctxt->context->node = bak;
13358 ctxt->context->proximityPosition = pp;
13359 ctxt->context->contextSize = cs;
13360 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13363 equal = xmlXPathEqualValues(ctxt);
13365 equal = xmlXPathNotEqualValues(ctxt);
13366 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, equal));
13369 bakd = ctxt->context->doc;
13370 bak = ctxt->context->node;
13371 pp = ctxt->context->proximityPosition;
13372 cs = ctxt->context->contextSize;
13373 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13375 ctxt->context->doc = bakd;
13376 ctxt->context->node = bak;
13377 ctxt->context->proximityPosition = pp;
13378 ctxt->context->contextSize = cs;
13379 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13381 ret = xmlXPathCompareValues(ctxt, op->value, op->value2);
13382 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, ret));
13385 bakd = ctxt->context->doc;
13386 bak = ctxt->context->node;
13387 pp = ctxt->context->proximityPosition;
13388 cs = ctxt->context->contextSize;
13389 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13392 ctxt->context->doc = bakd;
13393 ctxt->context->node = bak;
13394 ctxt->context->proximityPosition = pp;
13395 ctxt->context->contextSize = cs;
13396 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13400 xmlXPathSubValues(ctxt);
13402 xmlXPathAddValues(ctxt);
13404 xmlXPathValueFlipSign(ctxt);
13411 bakd = ctxt->context->doc;
13412 bak = ctxt->context->node;
13413 pp = ctxt->context->proximityPosition;
13414 cs = ctxt->context->contextSize;
13415 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13417 ctxt->context->doc = bakd;
13418 ctxt->context->node = bak;
13419 ctxt->context->proximityPosition = pp;
13420 ctxt->context->contextSize = cs;
13421 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13424 xmlXPathMultValues(ctxt);
13426 xmlXPathDivValues(ctxt);
13428 xmlXPathModValues(ctxt);
13431 bakd = ctxt->context->doc;
13432 bak = ctxt->context->node;
13433 pp = ctxt->context->proximityPosition;
13434 cs = ctxt->context->contextSize;
13435 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13437 ctxt->context->doc = bakd;
13438 ctxt->context->node = bak;
13439 ctxt->context->proximityPosition = pp;
13440 ctxt->context->contextSize = cs;
13441 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13444 arg2 = valuePop(ctxt);
13447 arg1 = valuePop(ctxt);
13457 valuePush(ctxt, arg1);
13458 xmlXPathReleaseObject(ctxt->context, arg2);
13461 xmlXPathRoot(ctxt);
13465 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13468 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13470 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
13471 ctxt->context->node));
13475 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13478 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13480 ctxt->context->node = NULL;
13486 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13489 total += xmlXPathNodeCollectAndTest(ctxt, op, NULL, NULL, 0);
13493 valuePush(ctxt,
13494 xmlXPathCacheObjectCopy(ctxt->context,
13502 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13504 val = xmlXPathVariableLookup(ctxt->context, op->value4);
13506 ctxt->error = XPATH_UNDEF_VARIABLE_ERROR;
13509 valuePush(ctxt, val);
13513 URI = xmlXPathNsLookup(ctxt->context, op->value5);
13518 ctxt->error = XPATH_UNDEF_PREFIX_ERROR;
13521 val = xmlXPathVariableLookupNS(ctxt->context,
13524 ctxt->error = XPATH_UNDEF_VARIABLE_ERROR;
13527 valuePush(ctxt, val);
13537 frame = xmlXPathSetFrame(ctxt);
13540 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13541 if (ctxt->error != XPATH_EXPRESSION_OK) {
13542 xmlXPathPopFrame(ctxt, frame);
13546 if (ctxt->valueNr < ctxt->valueFrame + op->value) {
13549 ctxt->error = XPATH_INVALID_OPERAND;
13550 xmlXPathPopFrame(ctxt, frame);
13554 if (ctxt->valueTab[(ctxt->valueNr - 1) - i] == NULL) {
13557 ctxt->error = XPATH_INVALID_OPERAND;
13558 xmlXPathPopFrame(ctxt, frame);
13569 xmlXPathFunctionLookup(ctxt->context,
13572 URI = xmlXPathNsLookup(ctxt->context, op->value5);
13577 xmlXPathPopFrame(ctxt, frame);
13578 ctxt->error = XPATH_UNDEF_PREFIX_ERROR;
13581 func = xmlXPathFunctionLookupNS(ctxt->context,
13593 oldFunc = ctxt->context->function;
13594 oldFuncURI = ctxt->context->functionURI;
13595 ctxt->context->function = op->value4;
13596 ctxt->context->functionURI = op->cacheURI;
13597 func(ctxt, op->value);
13598 ctxt->context->function = oldFunc;
13599 ctxt->context->functionURI = oldFuncURI;
13600 xmlXPathPopFrame(ctxt, frame);
13604 bakd = ctxt->context->doc;
13605 bak = ctxt->context->node;
13606 pp = ctxt->context->proximityPosition;
13607 cs = ctxt->context->contextSize;
13609 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13610 ctxt->context->contextSize = cs;
13611 ctxt->context->proximityPosition = pp;
13612 ctxt->context->node = bak;
13613 ctxt->context->doc = bakd;
13617 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13618 ctxt->context->contextSize = cs;
13619 ctxt->context->proximityPosition = pp;
13620 ctxt->context->node = bak;
13621 ctxt->context->doc = bakd;
13663 xmlXPathCompOpEvalFirst(ctxt,
13671 if ((ctxt->value != NULL) &&
13672 (ctxt->value->type == XPATH_NODESET) &&
13673 (ctxt->value->nodesetval != NULL) &&
13674 (ctxt->value->nodesetval->nodeNr > 1))
13675 ctxt->value->nodesetval->nodeNr = 1;
13697 xmlXPathCompOpEvalLast(ctxt,
13705 if ((ctxt->value != NULL) &&
13706 (ctxt->value->type == XPATH_NODESET) &&
13707 (ctxt->value->nodesetval != NULL) &&
13708 (ctxt->value->nodesetval->nodeTab != NULL) &&
13709 (ctxt->value->nodesetval->nodeNr > 1)) {
13710 ctxt->value->nodesetval->nodeTab[0] =
13711 ctxt->value->nodesetval->nodeTab[ctxt->
13716 ctxt->value->nodesetval->nodeNr = 1;
13734 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13738 if (ctxt->value == NULL)
13741 oldnode = ctxt->context->node;
13747 if (ctxt->value->type == XPATH_LOCATIONSET) {
13757 obj = valuePop(ctxt);
13759 ctxt->context->node = NULL;
13762 ctxt->context->contextSize = 0;
13763 ctxt->context->proximityPosition = 0;
13766 xmlXPathCompOpEval(ctxt,
13768 res = valuePop(ctxt);
13770 xmlXPathReleaseObject(ctxt->context, res);
13772 valuePush(ctxt, obj);
13783 ctxt->context->node = oldlocset->locTab[i]->user;
13784 ctxt->context->contextSize = oldlocset->locNr;
13785 ctxt->context->proximityPosition = i + 1;
13786 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
13787 ctxt->context->node);
13788 valuePush(ctxt, tmp);
13792 xmlXPathCompOpEval(ctxt,
13794 if (ctxt->error != XPATH_EXPRESSION_OK) {
13803 res = valuePop(ctxt);
13804 if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
13814 xmlXPathReleaseObject(ctxt->context, res);
13816 if (ctxt->value == tmp) {
13817 res = valuePop(ctxt);
13818 xmlXPathReleaseObject(ctxt->context, res);
13821 ctxt->context->node = NULL;
13827 xmlXPathReleaseObject(ctxt->context, obj);
13828 ctxt->context->node = NULL;
13829 ctxt->context->contextSize = -1;
13830 ctxt->context->proximityPosition = -1;
13831 valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
13832 ctxt->context->node = oldnode;
13843 obj = valuePop(ctxt);
13846 oldnode = ctxt->context->node;
13847 oldDoc = ctxt->context->doc;
13848 ctxt->context->node = NULL;
13851 ctxt->context->contextSize = 0;
13852 ctxt->context->proximityPosition = 0;
13856 xmlXPathCompOpEval(ctxt,
13859 res = valuePop(ctxt);
13863 valuePush(ctxt, obj);
13864 ctxt->context->node = oldnode;
13905 ctxt->context->node = oldset->nodeTab[i];
13908 ctxt->context->doc = oldset->nodeTab[i]->doc;
13910 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
13911 ctxt->context->node);
13914 ctxt->context->node) < 0) {
13915 ctxt->error = XPATH_MEMORY_ERROR;
13918 valuePush(ctxt, tmp);
13919 ctxt->context->contextSize = oldset->nodeNr;
13920 ctxt->context->proximityPosition = i + 1;
13928 xmlXPathCompOpEval(ctxt,
13930 if (ctxt->error != XPATH_EXPRESSION_OK) {
13944 res = valuePop(ctxt);
13945 if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
13948 ctxt->error = XPATH_MEMORY_ERROR;
13955 xmlXPathReleaseObject(ctxt->context, res);
13957 if (ctxt->value == tmp) {
13958 valuePop(ctxt);
13967 ctxt->context->node = NULL;
13970 xmlXPathReleaseObject(ctxt->context, tmp);
13974 xmlXPathReleaseObject(ctxt->context, obj);
13975 ctxt->context->node = NULL;
13976 ctxt->context->contextSize = -1;
13977 ctxt->context->proximityPosition = -1;
13979 ctxt->context->doc = oldDoc;
13980 valuePush(ctxt,
13981 xmlXPathCacheWrapNodeSet(ctxt->context, newset));
13983 ctxt->context->node = oldnode;
13988 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13990 if ((ctxt->value != NULL) &&
13991 (ctxt->value->type == XPATH_NODESET) &&
13992 (ctxt->value->nodesetval != NULL) &&
13993 (ctxt->value->nodesetval->nodeNr > 1))
13995 xmlXPathNodeSetSort(ctxt->value->nodesetval);
14010 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
14013 if (ctxt->value == NULL) {
14019 if (ctxt->value->type == XPATH_LOCATIONSET) {
14026 obj = valuePop(ctxt);
14030 ctxt->context->node = NULL;
14031 ctxt->context->contextSize = 0;
14032 ctxt->context->proximityPosition = 0;
14033 total += xmlXPathCompOpEval(ctxt,&comp->steps[op->ch2]);
14034 res = valuePop(ctxt);
14036 xmlXPathReleaseObject(ctxt->context, res);
14038 valuePush(ctxt, obj);
14049 ctxt->context->node = oldlocset->locTab[i]->user;
14050 ctxt->context->contextSize = oldlocset->locNr;
14051 ctxt->context->proximityPosition = i + 1;
14052 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
14053 ctxt->context->node);
14054 valuePush(ctxt, tmp);
14058 xmlXPathCompOpEval(ctxt,
14060 if (ctxt->error != XPATH_EXPRESSION_OK) {
14065 res = valuePop(ctxt);
14091 xmlXPathReleaseObject(ctxt->context, res);
14093 if (ctxt->value == tmp) {
14094 res = valuePop(ctxt);
14095 xmlXPathReleaseObject(ctxt->context, res);
14098 ctxt->context->node = NULL;
14102 obj = valuePop(ctxt);
14104 ctxt->context->node = NULL;
14114 ctxt->context->node = oldset->nodeTab[i];
14118 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
14119 ctxt->context->node);
14120 valuePush(ctxt, tmp);
14124 xmlXPathCompOpEval(ctxt,
14126 if (ctxt->error != XPATH_EXPRESSION_OK) {
14131 res = valuePop(ctxt);
14143 xmlXPathReleaseObject(ctxt->context, res);
14145 if (ctxt->value == tmp) {
14146 res = valuePop(ctxt);
14147 xmlXPathReleaseObject(ctxt->context, res);
14150 ctxt->context->node = NULL;
14158 xmlXPathReleaseObject(ctxt->context, obj);
14159 ctxt->context->node = NULL;
14160 ctxt->context->contextSize = -1;
14161 ctxt->context->proximityPosition = -1;
14162 valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
14169 ctxt->error = XPATH_INVALID_OPERAND;
14175 * @ctxt: the XPath parser context
14182 xmlXPathCompOpEvalToBoolean(xmlXPathParserContextPtr ctxt,
14189 /* comp = ctxt->comp; */
14196 return(xmlXPathEvaluatePredicateResult(ctxt, resObj));
14203 op = &ctxt->comp->steps[op->ch1];
14211 xmlXPathCompOpEval(ctxt, &ctxt->comp->steps[op->ch1]);
14212 if (ctxt->error != XPATH_EXPRESSION_OK)
14215 xmlXPathNodeCollectAndTest(ctxt, op, NULL, NULL, 1);
14216 if (ctxt->error != XPATH_EXPRESSION_OK)
14219 resObj = valuePop(ctxt);
14227 xmlXPathCompOpEval(ctxt, op);
14228 if (ctxt->error != XPATH_EXPRESSION_OK)
14231 resObj = valuePop(ctxt);
14251 res = xmlXPathEvaluatePredicateResult(ctxt, resObj);
14255 xmlXPathReleaseObject(ctxt->context, resObj);
14265 * @ctxt: the XPath parser context with the compiled expression
14270 xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp,
14282 if ((ctxt == NULL) || (comp == NULL))
14302 *resultSeq = xmlXPathCacheNewNodeSet(ctxt, NULL);
14316 (xmlNodePtr) ctxt->doc);
14321 xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, ctxt->node);
14329 cur = (xmlNodePtr)ctxt->doc;
14330 } else if (ctxt->node != NULL) {
14331 switch (ctxt->node->type) {
14339 cur = ctxt->node;
14411 ctxt->lastError.domain = XML_FROM_XPATH;
14412 ctxt->lastError.code = XML_ERR_NO_MEMORY;
14498 * @ctxt: the XPath parser context with the compiled expression
14504 xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
14508 if ((ctxt == NULL) || (ctxt->comp == NULL))
14511 if (ctxt->valueTab == NULL) {
14513 ctxt->valueTab = (xmlXPathObjectPtr *)
14515 if (ctxt->valueTab == NULL) {
14516 xmlXPathPErrMemory(ctxt, "creating evaluation context\n");
14517 xmlFree(ctxt);
14519 ctxt->valueNr = 0;
14520 ctxt->valueMax = 10;
14521 ctxt->value = NULL;
14522 ctxt->valueFrame = 0;
14525 if (ctxt->comp->stream) {
14532 res = xmlXPathRunStreamEval(ctxt->context,
14533 ctxt->comp->stream, NULL, 1);
14542 res = xmlXPathRunStreamEval(ctxt->context,
14543 ctxt->comp->stream, &resObj, 0);
14546 valuePush(ctxt, resObj);
14550 xmlXPathReleaseObject(ctxt->context, resObj);
14558 comp = ctxt->comp;
14565 return(xmlXPathCompOpEvalToBoolean(ctxt,
14568 xmlXPathCompOpEval(ctxt, &comp->steps[comp->last]);
14581 * @ctxt: the XPath context
14596 xmlXPathEvalPredicate(xmlXPathContextPtr ctxt, xmlXPathObjectPtr res) {
14597 if ((ctxt == NULL) || (res == NULL)) return(0);
14602 return(res->floatval == ctxt->proximityPosition);
14619 * @ctxt: the XPath Parser context
14634 xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
14636 if ((ctxt == NULL) || (res == NULL)) return(0);
14642 return((res->floatval == ctxt->context->proximityPosition) &&
14645 return(res->floatval == ctxt->context->proximityPosition);
14671 * @ctxt: an XPath context
14679 xmlXPathTryStreamCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
14706 ((ctxt == NULL) || (ctxt->nsNr == 0) || (tmp[1] == ':')))
14709 if (ctxt != NULL) {
14710 dict = ctxt->dict;
14711 if (ctxt->nsNr > 0) {
14712 namespaces = xmlMalloc(2 * (ctxt->nsNr + 1) * sizeof(xmlChar*));
14714 xmlXPathErrMemory(ctxt, "allocating namespaces array\n");
14717 for (i = 0, j = 0; (j < ctxt->nsNr); j++) {
14718 ns = ctxt->namespaces[j];
14735 xmlXPathErrMemory(ctxt, "allocating streamable expression\n");
14816 * @ctxt: an XPath context
14825 xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
14830 comp = xmlXPathTryStreamCompile(ctxt, str);
14837 pctxt = xmlXPathNewParserContext(str, ctxt);
14893 * @ctxt: the XPath context
14905 xmlXPathContextPtr ctxt,
14915 CHECK_CTXT_NEG(ctxt)
14934 pctxt = xmlXPathCompParserContext(comp, ctxt);
14958 xmlXPathReleaseObject(ctxt, tmp);
15005 * @ctxt: the XPath context
15015 xmlXPathContextPtr ctxt)
15017 return(xmlXPathCompiledEvalInternal(comp, ctxt, NULL, 1));
15022 * @ctxt: the XPath Parser context
15028 xmlXPathEvalExpr(xmlXPathParserContextPtr ctxt) {
15033 if (ctxt == NULL) return;
15036 comp = xmlXPathTryStreamCompile(ctxt->context, ctxt->base);
15038 if (ctxt->comp != NULL)
15039 xmlXPathFreeCompExpr(ctxt->comp);
15040 ctxt->comp = comp;
15041 if (ctxt->cur != NULL)
15042 while (*ctxt->cur != 0) ctxt->cur++;
15046 xmlXPathCompileExpr(ctxt, 1);
15047 if ((ctxt->error == XPATH_EXPRESSION_OK) &&
15048 (ctxt->comp != NULL) &&
15049 (ctxt->comp->nbStep > 1) &&
15050 (ctxt->comp->last >= 0))
15052 xmlXPathOptimizeExpression(ctxt->comp,
15053 &ctxt->comp->steps[ctxt->comp->last]);
15057 xmlXPathRunEval(ctxt, 0);
15072 xmlXPathParserContextPtr ctxt;
15080 ctxt = xmlXPathNewParserContext(str, ctx);
15081 if (ctxt == NULL)
15083 xmlXPathEvalExpr(ctxt);
15085 if (ctxt->value == NULL) {
15089 } else if ((*ctxt->cur != 0) && (ctxt->comp != NULL)
15091 && (ctxt->comp->stream == NULL)
15094 xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_EXPR_ERROR);
15097 res = valuePop(ctxt);
15101 tmp = valuePop(ctxt);
15113 if (ctxt->error != XPATH_EXPRESSION_OK) {
15118 xmlXPathFreeParserContext(ctxt);
15168 * @ctxt: the XPath context
15176 xmlXPathEvalExpression(const xmlChar *str, xmlXPathContextPtr ctxt) {
15181 CHECK_CTXT(ctxt)
15185 pctxt = xmlXPathNewParserContext(str, ctxt);
15199 xmlXPathReleaseObject(ctxt, tmp);
15219 * @ctxt: the XPath Parser context
15266 xmlXPathEscapeUriFunction(xmlXPathParserContextPtr ctxt, int nargs) {
15275 escape_reserved = xmlXPathPopBoolean(ctxt);
15278 str = valuePop(ctxt);
15320 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
15323 xmlXPathReleaseObject(ctxt->context, str);
15328 * @ctxt: the XPath context
15333 xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt)
15335 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"boolean",
15337 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"ceiling",
15339 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"count",
15341 xmlXPathRegisterFunc(ctxt
15343 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"contains",
15345 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"id",
15347 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"false",
15349 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"floor",
15351 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"last",
15353 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"lang",
15355 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"local-name",
15357 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"not",
15359 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"name",
15361 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"namespace-uri",
15363 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"normalize-space",
15365 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"number",
15367 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"position",
15369 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"round",
15371 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"string",
15373 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"string-length",
15375 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"starts-with",
15377 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring",
15379 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring-before",
15381 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring-after",
15383 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"sum",
15385 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"true",
15387 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"translate",
15390 xmlXPathRegisterFuncNS(ctxt, (const xmlChar *)"escape-uri",