Home | History | Annotate | Download | only in libxml2

Lines Matching defs:ctxt

226     { xmlXPathErr(ctxt, X); return(NULL); }
262 * @ctxt: an XPath context
268 xmlXPathErrMemory(xmlXPathContextPtr ctxt, const char *extra)
270 if (ctxt != NULL) {
277 ctxt->lastError.message = (char *) xmlStrdup(buf);
279 ctxt->lastError.message = (char *)
282 ctxt->lastError.domain = XML_FROM_XPATH;
283 ctxt->lastError.code = XML_ERR_NO_MEMORY;
284 if (ctxt->error != NULL)
285 ctxt->error(ctxt->userData, &ctxt->lastError);
304 * @ctxt: an XPath parser context
310 xmlXPathPErrMemory(xmlXPathParserContextPtr ctxt, const char *extra)
312 if (ctxt == NULL)
315 ctxt->error = XPATH_MEMORY_ERROR;
316 xmlXPathErrMemory(ctxt->context, extra);
322 * @ctxt: a XPath parser context
328 xmlXPathErr(xmlXPathParserContextPtr ctxt, int error)
332 if (ctxt == NULL) {
341 ctxt->error = error;
342 if (ctxt->context == NULL) {
347 (const char *) ctxt->base, NULL, NULL,
348 ctxt->cur - ctxt->base, 0,
354 xmlResetError(&ctxt->context->lastError);
356 ctxt->context->lastError.domain = XML_FROM_XPATH;
357 ctxt->context->lastError.code = error + XML_XPATH_EXPRESSION_OK -
359 ctxt->context->lastError.level = XML_ERR_ERROR;
360 ctxt->context->lastError.str1 = (char *) xmlStrdup(ctxt->base);
361 ctxt->context->lastError.int1 = ctxt->cur - ctxt->base;
362 ctxt->context->lastError.node = ctxt->context->debugNode;
363 if (ctxt->context->error != NULL) {
364 ctxt->context->error(ctxt->context->userData,
365 &ctxt->context->lastError);
368 NULL, ctxt->context->debugNode, XML_FROM_XPATH,
371 (const char *) ctxt->base, NULL, NULL,
372 ctxt->cur - ctxt->base, 0,
380 * @ctxt: the XPath Parser context
388 xmlXPatherror(xmlXPathParserContextPtr ctxt, const char *file ATTRIBUTE_UNUSED,
390 xmlXPathErr(ctxt, no);
598 xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj);
600 xmlXPathCompOpEvalFirst(xmlXPathParserContextPtr ctxt,
603 xmlXPathCompOpEvalToBoolean(xmlXPathParserContextPtr ctxt,
794 xmlXPathCompExprAdd(ctxt->comp, (op1), (op2), \
797 xmlXPathCompExprAdd(ctxt->comp, ctxt->comp->last, -1, \
801 xmlXPathCompExprAdd(ctxt->comp, -1, -1, (op), (val), (val2), 0 ,NULL ,NULL)
804 xmlXPathCompExprAdd(ctxt->comp, (ch), -1, (op), (val), (val2), 0 ,NULL ,NULL)
807 xmlXPathCompExprAdd(ctxt->comp, (ch1), (ch2), (op), \
1353 xmlXPathDebugObjUsageReset(xmlXPathContextPtr ctxt)
1355 if (ctxt != NULL) {
1356 if (ctxt->cache != NULL) {
1358 (xmlXPathContextCachePtr) ctxt->cache;
1425 xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
1430 if (ctxt != NULL) {
1431 if (ctxt->cache != NULL) {
1433 (xmlXPathContextCachePtr) ctxt->cache;
1579 xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
1584 if (ctxt != NULL) {
1585 if (ctxt->cache != NULL) {
1587 (xmlXPathContextCachePtr) ctxt->cache;
1668 xmlXPathDebugObjUsageDisplay(xmlXPathContextPtr ctxt)
1688 if (ctxt != NULL) {
1689 if (ctxt->cache != NULL) {
1691 (xmlXPathContextCachePtr) ctxt->cache;
1859 * @ctxt: the XPath context
1879 xmlXPathContextSetCache(xmlXPathContextPtr ctxt,
1884 if (ctxt == NULL)
1889 if (ctxt->cache == NULL) {
1890 ctxt->cache = xmlXPathNewCache();
1891 if (ctxt->cache == NULL)
1894 cache = (xmlXPathContextCachePtr) ctxt->cache;
1904 } else if (ctxt->cache != NULL) {
1905 xmlXPathFreeCache((xmlXPathContextCachePtr) ctxt->cache);
1906 ctxt->cache = NULL;
1913 * @ctxt: the XPath context
1922 xmlXPathCacheWrapNodeSet(xmlXPathContextPtr ctxt, xmlNodeSetPtr val)
1924 if ((ctxt != NULL) && (ctxt->cache != NULL)) {
1926 (xmlXPathContextCachePtr) ctxt->cache;
1938 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
1950 * @ctxt: the XPath context
1959 xmlXPathCacheWrapString(xmlXPathContextPtr ctxt, xmlChar *val)
1961 if ((ctxt != NULL) && (ctxt->cache != NULL)) {
1962 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
1975 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
1991 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2001 * @ctxt: the XPath context
2011 xmlXPathCacheNewNodeSet(xmlXPathContextPtr ctxt, xmlNodePtr val)
2013 if ((ctxt != NULL) && (ctxt->cache)) {
2014 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2038 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
2056 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
2066 * @ctxt: the XPath context
2075 xmlXPathCacheNewCString(xmlXPathContextPtr ctxt, const char *val)
2077 if ((ctxt != NULL) && (ctxt->cache)) {
2078 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2091 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2105 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2115 * @ctxt: the XPath context
2124 xmlXPathCacheNewString(xmlXPathContextPtr ctxt, const xmlChar *val)
2126 if ((ctxt != NULL) && (ctxt->cache)) {
2127 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2142 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2159 xmlXPathDebugObjUsageRequested(ctxt, XPATH_STRING);
2169 * @ctxt: the XPath context
2178 xmlXPathCacheNewBoolean(xmlXPathContextPtr ctxt, int val)
2180 if ((ctxt != NULL) && (ctxt->cache)) {
2181 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2193 xmlXPathDebugObjUsageRequested(ctxt, XPATH_BOOLEAN);
2207 xmlXPathDebugObjUsageRequested(ctxt, XPATH_BOOLEAN);
2217 * @ctxt: the XPath context
2226 xmlXPathCacheNewFloat(xmlXPathContextPtr ctxt, double val)
2228 if ((ctxt != NULL) && (ctxt->cache)) {
2229 xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
2241 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NUMBER);
2255 xmlXPathDebugObjUsageRequested(ctxt, XPATH_NUMBER);
2265 * @ctxt: the XPath context
2276 xmlXPathCacheConvertString(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
2280 return(xmlXPathCacheNewCString(ctxt, ""));
2307 xmlXPathReleaseObject(ctxt, val);
2309 return(xmlXPathCacheNewCString(ctxt, ""));
2310 return(xmlXPathCacheWrapString(ctxt, res));
2315 * @ctxt: the XPath context
2324 xmlXPathCacheObjectCopy(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val)
2329 if (XP_HAS_CACHE(ctxt)) {
2332 return(xmlXPathCacheWrapNodeSet(ctxt,
2335 return(xmlXPathCacheNewString(ctxt, val->stringval));
2337 return(xmlXPathCacheNewBoolean(ctxt, val->boolval));
2339 return(xmlXPathCacheNewFloat(ctxt, val->floatval));
2349 * @ctxt: the XPath context
2359 xmlXPathCacheConvertBoolean(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
2363 return(xmlXPathCacheNewBoolean(ctxt, 0));
2366 ret = xmlXPathCacheNewBoolean(ctxt, xmlXPathCastToBoolean(val));
2367 xmlXPathReleaseObject(ctxt, val);
2373 * @ctxt: the XPath context
2383 xmlXPathCacheConvertNumber(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
2387 return(xmlXPathCacheNewFloat(ctxt, 0.0));
2390 ret = xmlXPathCacheNewFloat(ctxt, xmlXPathCastToNumber(val));
2391 xmlXPathReleaseObject(ctxt, val);
2403 * @ctxt: an XPath parser context
2410 xmlXPathSetFrame(xmlXPathParserContextPtr ctxt) {
2413 if (ctxt == NULL)
2415 ret = ctxt->valueFrame;
2416 ctxt->valueFrame = ctxt->valueNr;
2422 * @ctxt: an XPath parser context
2428 xmlXPathPopFrame(xmlXPathParserContextPtr ctxt, int frame) {
2429 if (ctxt == NULL)
2431 if (ctxt->valueNr < ctxt
2432 xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_STACK_ERROR);
2434 ctxt->valueFrame = frame;
2439 * @ctxt: an XPath evaluation context
2446 valuePop(xmlXPathParserContextPtr ctxt)
2450 if ((ctxt == NULL) || (ctxt->valueNr <= 0))
2453 if (ctxt->valueNr <= ctxt->valueFrame) {
2454 xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_STACK_ERROR);
2458 ctxt->valueNr--;
2459 if (ctxt->valueNr > 0)
2460 ctxt->value = ctxt->valueTab[ctxt->valueNr - 1];
2462 ctxt->value = NULL;
2463 ret = ctxt->valueTab[ctxt->valueNr];
2464 ctxt->valueTab[ctxt->valueNr] = NULL;
2469 * @ctxt: an XPath evaluation context
2477 valuePush(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value)
2479 if ((ctxt == NULL) || (value == NULL)) return(-1);
2480 if (ctxt->valueNr >= ctxt->valueMax) {
2483 tmp = (xmlXPathObjectPtr *) xmlRealloc(ctxt->valueTab,
2484 2 * ctxt->valueMax *
2485 sizeof(ctxt->valueTab[0]));
2488 ctxt->error = XPATH_MEMORY_ERROR;
2491 ctxt->valueMax *= 2;
2492 ctxt->valueTab = tmp;
2494 ctxt->valueTab[ctxt->valueNr] = value;
2495 ctxt->value = value;
2496 return (ctxt->valueNr++);
2501 * @ctxt: an XPath parser context
2509 xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt) {
2513 obj = valuePop(ctxt);
2515 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
2522 xmlXPathReleaseObject(ctxt->context, obj);
2528 * @ctxt: an XPath parser context
2536 xmlXPathPopNumber (xmlXPathParserContextPtr ctxt) {
2540 obj = valuePop(ctxt);
2542 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
2549 xmlXPathReleaseObject(ctxt->context, obj);
2555 * @ctxt: an XPath parser context
2563 xmlXPathPopString (xmlXPathParserContextPtr ctxt) {
2567 obj = valuePop(ctxt);
2569 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
2576 xmlXPathReleaseObject(ctxt->context, obj);
2582 * @ctxt: an XPath parser context
2590 xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt) {
2594 if (ctxt == NULL) return(NULL);
2595 if (ctxt->value == NULL) {
2596 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
2599 if (!xmlXPathStackIsNodeSet(ctxt)) {
2600 xmlXPathSetTypeError(ctxt);
2603 obj = valuePop(ctxt);
2611 xmlXPathReleaseObject(ctxt->context, obj);
2617 * @ctxt: an XPath parser context
2625 xmlXPathPopExternal (xmlXPathParserContextPtr ctxt) {
2629 if ((ctxt == NULL) || (ctxt->value == NULL)) {
2630 xmlXPathSetError(ctxt, XPATH_INVALID_OPERAND);
2633 if (ctxt->value->type != XPATH_USERS) {
2634 xmlXPathSetTypeError(ctxt);
2637 obj = valuePop(ctxt);
2640 xmlXPathReleaseObject(ctxt->context, obj);
2667 #define CUR (*ctxt->cur)
2668 #define SKIP(val) ctxt->cur += (val)
2669 #define NXT(val) ctxt->cur[(val)]
2670 #define CUR_PTR ctxt->cur
2671 #define CUR_CHAR(l) xmlXPathCurrentChar(ctxt, &l)
2677 #define NEXTL(l) ctxt->cur += l
2680 while (IS_BLANK_CH(*(ctxt->cur))) NEXT
2682 #define CURRENT (*ctxt->cur)
2683 #define NEXT ((*ctxt->cur) ? ctxt->cur++: ctxt->cur)
4761 * @ctxt: the XPath context
4770 xmlXPathRegisterFunc(xmlXPathContextPtr ctxt, const xmlChar *name,
4772 return(xmlXPathRegisterFuncNS(ctxt, name, NULL, f));
4777 * @ctxt: the XPath context
4787 xmlXPathRegisterFuncNS(xmlXPathContextPtr ctxt, const xmlChar *name,
4789 if (ctxt == NULL)
4794 if (ctxt->funcHash == NULL)
4795 ctxt->funcHash = xmlHashCreate(0);
4796 if (ctxt->funcHash == NULL)
4799 return(xmlHashRemoveEntry2(ctxt->funcHash, name, ns_uri, NULL));
4800 return(xmlHashAddEntry2(ctxt->funcHash, name, ns_uri, XML_CAST_FPTR(f)));
4805 * @ctxt: the XPath context
4812 xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
4815 if (ctxt == NULL)
4817 ctxt->funcLookupFunc = f;
4818 ctxt->funcLookupData = funcCtxt;
4823 * @ctxt: the XPath context
4832 xmlXPathFunctionLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
4833 if (ctxt == NULL)
4836 if (ctxt->funcLookupFunc != NULL) {
4840 f = ctxt->funcLookupFunc;
4841 ret = f(ctxt->funcLookupData, name, NULL);
4845 return(xmlXPathFunctionLookupNS(ctxt, name, NULL));
4850 * @ctxt: the XPath context
4860 xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
4864 if (ctxt == NULL)
4869 if (ctxt->funcLookupFunc != NULL) {
4872 f = ctxt->funcLookupFunc;
4873 ret = f(ctxt->funcLookupData, name, ns_uri);
4878 if (ctxt->funcHash == NULL)
4881 XML_CAST_FPTR(ret) = xmlHashLookup2(ctxt->funcHash, name, ns_uri);
4887 * @ctxt: the XPath context
4892 xmlXPathRegisteredFuncsCleanup(xmlXPathContextPtr ctxt) {
4893 if (ctxt == NULL)
4896 xmlHashFree(ctxt->funcHash, NULL);
4897 ctxt->funcHash = NULL;
4908 * @ctxt: the XPath context
4918 xmlXPathRegisterVariable(xmlXPathContextPtr ctxt, const xmlChar *name,
4920 return(xmlXPathRegisterVariableNS(ctxt, name, NULL, value));
4925 * @ctxt: the XPath context
4936 xmlXPathRegisterVariableNS(xmlXPathContextPtr ctxt, const xmlChar *name,
4939 if (ctxt == NULL)
4944 if (ctxt->varHash == NULL)
4945 ctxt->varHash = xmlHashCreate(0);
4946 if (ctxt->varHash == NULL)
4949 return(xmlHashRemoveEntry2(ctxt->varHash, name, ns_uri,
4951 return(xmlHashUpdateEntry2(ctxt->varHash, name, ns_uri,
4958 * @ctxt: the XPath context
4965 xmlXPathRegisterVariableLookup(xmlXPathContextPtr ctxt,
4967 if (ctxt == NULL)
4969 ctxt->varLookupFunc = f;
4970 ctxt->varLookupData = data;
4975 * @ctxt: the XPath context
4984 xmlXPathVariableLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
4985 if (ctxt == NULL)
4988 if (ctxt->varLookupFunc != NULL) {
4991 ret = ((xmlXPathVariableLookupFunc)ctxt->varLookupFunc)
4992 (ctxt->varLookupData, name, NULL);
4995 return(xmlXPathVariableLookupNS(ctxt, name, NULL));
5000 * @ctxt: the XPath context
5010 xmlXPathVariableLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
5012 if (ctxt == NULL)
5015 if (ctxt->varLookupFunc != NULL) {
5018 ret = ((xmlXPathVariableLookupFunc)ctxt->varLookupFunc)
5019 (ctxt->varLookupData, name, ns_uri);
5023 if (ctxt->varHash == NULL)
5028 return(xmlXPathCacheObjectCopy(ctxt, (xmlXPathObjectPtr)
5029 xmlHashLookup2(ctxt->varHash, name, ns_uri)));
5034 * @ctxt: the XPath context
5039 xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt) {
5040 if (ctxt == NULL)
5043 xmlHashFree(ctxt->varHash, (xmlHashDeallocator)xmlXPathFreeObject);
5044 ctxt->varHash = NULL;
5049 * @ctxt: the XPath context
5059 xmlXPathRegisterNs(xmlXPathContextPtr ctxt, const xmlChar *prefix,
5061 if (ctxt == NULL)
5068 if (ctxt->nsHash == NULL)
5069 ctxt->nsHash = xmlHashCreate(10);
5070 if (ctxt->nsHash == NULL)
5073 return(xmlHashRemoveEntry(ctxt->nsHash, prefix,
5075 return(xmlHashUpdateEntry(ctxt->nsHash, prefix, (void *) xmlStrdup(ns_uri),
5081 * @ctxt: the XPath context
5090 xmlXPathNsLookup(xmlXPathContextPtr ctxt, const xmlChar *prefix) {
5091 if (ctxt == NULL)
5101 if (ctxt->namespaces != NULL) {
5104 for (i = 0;i < ctxt->nsNr;i++) {
5105 if ((ctxt->namespaces[i] != NULL) &&
5106 (xmlStrEqual(ctxt->namespaces[i]->prefix, prefix)))
5107 return(ctxt->namespaces[i]->href);
5111 return((const xmlChar *) xmlHashLookup(ctxt->nsHash, prefix));
5116 * @ctxt: the XPath context
5121 xmlXPathRegisteredNsCleanup(xmlXPathContextPtr ctxt) {
5122 if (ctxt == NULL)
5125 xmlHashFree(ctxt->nsHash, (xmlHashDeallocator)xmlFree);
5126 ctxt->nsHash = NULL;
5447 xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj)
5457 if ((ctxt == NULL) || (ctxt->cache == NULL)) {
5461 (xmlXPathContextCachePtr) ctxt->cache;
5531 xmlXPathDebugObjUsageReleased(ctxt, obj->type);
6080 * @ctxt: the context to free
6085 xmlXPathFreeContext(xmlXPathContextPtr ctxt) {
6086 if (ctxt == NULL) return;
6088 if (ctxt->cache != NULL)
6089 xmlXPathFreeCache((xmlXPathContextCachePtr) ctxt->cache);
6090 xmlXPathRegisteredNsCleanup(ctxt);
6091 xmlXPathRegisteredFuncsCleanup(ctxt);
6092 xmlXPathRegisteredVariablesCleanup(ctxt);
6093 xmlResetError(&ctxt->lastError);
6094 xmlFree(ctxt);
6103 #define CHECK_CTXT(ctxt) \
6104 if (ctxt == NULL) { \
6114 #define CHECK_CTXT_NEG(ctxt) \
6115 if (ctxt == NULL) { \
6126 #define CHECK_CONTEXT(ctxt) \
6127 if ((ctxt == NULL) || (ctxt->doc == NULL) || \
6128 (ctxt->doc->children == NULL)) { \
6129 xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_INVALID_CTXT); \
6137 * @ctxt: the XPath context
6144 xmlXPathNewParserContext(const xmlChar *str, xmlXPathContextPtr ctxt) {
6149 xmlXPathErrMemory(ctxt, "creating parser context\n");
6154 ret->context = ctxt;
6162 if ((ctxt != NULL) && (ctxt->dict != NULL)) {
6163 ret->comp->dict = ctxt->dict;
6173 * @ctxt: the XPath context
6180 xmlXPathCompParserContext(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt) {
6185 xmlXPathErrMemory(ctxt, "creating evaluation context\n");
6195 xmlXPathErrMemory(ctxt, "creating evaluation context\n");
6203 ret->context = ctxt;
6211 * @ctxt: the context to free
6216 xmlXPathFreeParserContext(xmlXPathParserContextPtr ctxt) {
6217 if (ctxt->valueTab != NULL) {
6218 xmlFree(ctxt->valueTab);
6220 if (ctxt->comp != NULL) {
6222 if (ctxt->comp->stream != NULL) {
6223 xmlFreePatternList(ctxt->comp->stream);
6224 ctxt->comp->stream = NULL;
6227 xmlXPathFreeCompExpr(ctxt->comp);
6229 xmlFree(ctxt);
6378 * @ctxt: the XPath Parser context
6399 xmlXPathCompareNodeSetFloat(xmlXPathParserContextPtr ctxt, int inf, int strict,
6407 xmlXPathReleaseObject(ctxt->context, arg);
6408 xmlXPathReleaseObject(ctxt->context, f);
6416 valuePush(ctxt,
6417 xmlXPathCacheNewString(ctxt->context, str2));
6419 xmlXPathNumberFunction(ctxt, 1);
6420 valuePush(ctxt, xmlXPathCacheObjectCopy(ctxt->context, f));
6421 ret = xmlXPathCompareValues(ctxt, inf, strict);
6427 xmlXPathReleaseObject(ctxt->context, arg);
6428 xmlXPathReleaseObject(ctxt->context, f);
6434 * @ctxt: the XPath Parser context
6454 xmlXPathCompareNodeSetString(xmlXPathParserContextPtr ctxt, int inf, int strict,
6462 xmlXPathReleaseObject(ctxt->context, arg);
6463 xmlXPathReleaseObject(ctxt->context, s);
6471 valuePush(ctxt,
6472 xmlXPathCacheNewString(ctxt->context, str2));
6474 valuePush(ctxt, xmlXPathCacheObjectCopy(ctxt->context, s));
6475 ret = xmlXPathCompareValues(ctxt, inf, strict);
6481 xmlXPathReleaseObject(ctxt->context, arg);
6482 xmlXPathReleaseObject(ctxt->context, s);
6590 * @ctxt: the XPath Parser context
6610 xmlXPathCompareNodeSetValue(xmlXPathParserContextPtr ctxt, int inf, int strict,
6618 return(xmlXPathCompareNodeSetFloat(ctxt, inf, strict, arg, val));
6623 return(xmlXPathCompareNodeSetString(ctxt, inf, strict, arg, val));
6625 valuePush(ctxt, arg);
6626 xmlXPathBooleanFunction(ctxt, 1);
6627 valuePush(ctxt, val);
6628 return(xmlXPathCompareValues(ctxt, inf, strict));
6709 xmlXPathEqualNodeSetFloat(xmlXPathParserContextPtr ctxt,
6726 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, str2));
6728 xmlXPathNumberFunction(ctxt, 1);
6729 val = valuePop(ctxt);
6731 xmlXPathReleaseObject(ctxt->context, val);
6870 xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
6935 valuePush(ctxt, arg2);
6936 xmlXPathNumberFunction(ctxt, 1);
6937 arg2 = valuePop(ctxt);
6998 valuePush(ctxt, arg1);
6999 xmlXPathNumberFunction(ctxt, 1);
7000 arg1 = valuePop(ctxt);
7050 xmlXPathReleaseObject(ctxt->context, arg1);
7051 xmlXPathReleaseObject(ctxt->context, arg2);
7057 * @ctxt: the XPath Parser context
7064 xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
7068 if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
7069 arg2 = valuePop(ctxt);
7070 arg1 = valuePop(ctxt);
7073 xmlXPathReleaseObject(ctxt->context, arg1);
7075 xmlXPathReleaseObject(ctxt->context, arg2);
7120 ret = xmlXPathEqualNodeSetFloat(ctxt, arg1, arg2->floatval, 0);
7132 xmlXPathReleaseObject(ctxt->context, arg1);
7133 xmlXPathReleaseObject(ctxt->context, arg2);
7137 return (xmlXPathEqualValuesCommon(ctxt, arg1, arg2));
7142 * @ctxt: the XPath Parser context
7149 xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt) {
7153 if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
7154 arg2 = valuePop(ctxt);
7155 arg1 = valuePop(ctxt);
7158 xmlXPathReleaseObject(ctxt->context, arg1);
7160 xmlXPathReleaseObject(ctxt->context, arg2);
7169 xmlXPathReleaseObject(ctxt->context, arg1);
7205 ret = xmlXPathEqualNodeSetFloat(ctxt, arg1, arg2->floatval, 1);
7217 xmlXPathReleaseObject(ctxt->context, arg1);
7218 xmlXPathReleaseObject(ctxt->context, arg2);
7222 return (!xmlXPathEqualValuesCommon(ctxt, arg1, arg2));
7227 * @ctxt: the XPath Parser context
7250 xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict) {
7254 if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
7255 arg2 = valuePop(ctxt);
7256 arg1 = valuePop(ctxt);
7259 xmlXPathReleaseObject(ctxt->context, arg1);
7261 xmlXPathReleaseObject(ctxt->context, arg2);
7277 ret = xmlXPathCompareNodeSetValue(ctxt, inf, strict,
7280 ret = xmlXPathCompareNodeSetValue(ctxt, !inf, strict,
7288 valuePush(ctxt, arg1);
7289 xmlXPathNumberFunction(ctxt, 1);
7290 arg1 = valuePop(ctxt);
7298 valuePush(ctxt, arg2);
7299 xmlXPathNumberFunction(ctxt, 1);
7300 arg2 = valuePop(ctxt);
7303 xmlXPathReleaseObject(ctxt->context, arg1);
7304 xmlXPathReleaseObject(ctxt->context, arg2);
7356 xmlXPathReleaseObject(ctxt->context, arg1);
7357 xmlXPathReleaseObject(ctxt->context, arg2);
7363 * @ctxt: the XPath Parser context
7370 xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt) {
7371 if ((ctxt == NULL) || (ctxt->context == NULL)) return;
7374 if (xmlXPathIsNaN(ctxt->value->floatval))
7375 ctxt->value->floatval=xmlXPathNAN;
7376 else if (xmlXPathIsInf(ctxt->value->floatval) == 1)
7377 ctxt->value->floatval=xmlXPathNINF;
7378 else if (xmlXPathIsInf(ctxt->value->floatval) == -1)
7379 ctxt->value->floatval=xmlXPathPINF;
7380 else if (ctxt->value->floatval == 0) {
7381 if (xmlXPathGetSign(ctxt->value->floatval) == 0)
7382 ctxt->value->floatval = xmlXPathNZERO;
7384 ctxt->value->floatval = 0;
7387 ctxt->value->floatval = - ctxt->value->floatval;
7392 * @ctxt: the XPath Parser context
7399 xmlXPathAddValues(xmlXPathParserContextPtr ctxt) {
7403 arg = valuePop(ctxt);
7407 xmlXPathReleaseObject(ctxt->context, arg);
7410 ctxt->value->floatval += val;
7415 * @ctxt: the XPath Parser context
7422 xmlXPathSubValues(xmlXPathParserContextPtr ctxt) {
7426 arg = valuePop(ctxt);
7430 xmlXPathReleaseObject(ctxt->context, arg);
7433 ctxt->value->floatval -= val;
7438 * @ctxt: the XPath Parser context
7445 xmlXPathMultValues(xmlXPathParserContextPtr ctxt) {
7449 arg = valuePop(ctxt);
7453 xmlXPathReleaseObject(ctxt->context, arg);
7456 ctxt->value->floatval *= val;
7461 * @ctxt: the XPath Parser context
7468 xmlXPathDivValues(xmlXPathParserContextPtr ctxt) {
7472 arg = valuePop(ctxt);
7476 xmlXPathReleaseObject(ctxt->context, arg);
7479 if (xmlXPathIsNaN(val) || xmlXPathIsNaN(ctxt->value->floatval))
7480 ctxt->value->floatval = xmlXPathNAN;
7482 if (ctxt->value->floatval == 0)
7483 ctxt->value->floatval = xmlXPathNAN;
7484 else if (ctxt->value->floatval > 0)
7485 ctxt->value->floatval = xmlXPathNINF;
7486 else if (ctxt->value->floatval < 0)
7487 ctxt->value->floatval = xmlXPathPINF;
7490 if (ctxt->value->floatval == 0)
7491 ctxt->value->floatval = xmlXPathNAN;
7492 else if (ctxt->value->floatval > 0)
7493 ctxt->value->floatval = xmlXPathPINF;
7494 else if (ctxt->value->floatval < 0)
7495 ctxt->value->floatval = xmlXPathNINF;
7497 ctxt->value->floatval /= val;
7502 * @ctxt: the XPath Parser context
7509 xmlXPathModValues(xmlXPathParserContextPtr ctxt) {
7513 arg = valuePop(ctxt);
7517 xmlXPathReleaseObject(ctxt->context, arg);
7520 arg1 = ctxt->value->floatval;
7522 ctxt->value->floatval = xmlXPathNAN;
7524 ctxt->value->floatval = fmod(arg1, arg2);
7540 (xmlXPathParserContextPtr ctxt, xmlNodePtr cur);
7562 * @ctxt: the XPath Parser context
7571 xmlXPathNextSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7572 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7574 return(ctxt->context->node);
7580 * @ctxt: the XPath Parser context
7589 xmlXPathNextChild(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7590 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7592 if (ctxt->context->node == NULL) return(NULL);
7593 switch (ctxt->context->node->type) {
7603 return(ctxt->context->node->children);
7611 return(((xmlDocPtr) ctxt->context->node)->children);
7631 * @ctxt: the XPath Parser context
7640 xmlXPathNextChildElement(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7641 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7643 cur = ctxt->context->node;
7706 * @ctxt: the XPath Parser context
7782 * @ctxt: the XPath Parser context
7792 xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7793 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7795 if (ctxt->context->node == NULL)
7797 if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
7798 (ctxt->context->node->type == XML_NAMESPACE_DECL))
7801 if (ctxt->context->node == (xmlNodePtr) ctxt->context->doc)
7802 return(ctxt->context->doc->children);
7803 return(ctxt->context->node->children);
7820 if (cur == ctxt->context->node) return(NULL);
7832 if (cur == ctxt->context->node) return(NULL);
7843 * @ctxt: the XPath Parser context
7855 xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7856 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7858 if (ctxt->context->node == NULL)
7860 if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
7861 (ctxt->context->node->type == XML_NAMESPACE_DECL))
7863 return(ctxt->context->node);
7866 return(xmlXPathNextDescendant(ctxt, cur));
7871 * @ctxt: the XPath Parser context
7880 xmlXPathNextParent(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7881 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7888 if (ctxt->context->node == NULL) return(NULL);
7889 switch (ctxt->context->node->type) {
7904 if (ctxt->context->node->parent == NULL)
7905 return((xmlNodePtr) ctxt->context->doc);
7906 if ((ctxt->context->node->parent->type == XML_ELEMENT_NODE) &&
7907 ((ctxt->context->node->parent->name[0] == ' ') ||
7908 (xmlStrEqual(ctxt->context->node->parent->name,
7911 return(ctxt->context->node->parent);
7913 xmlAttrPtr att = (xmlAttrPtr) ctxt->context->node;
7926 xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
7940 * @ctxt: the XPath Parser context
7953 xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
7954 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
7961 if (ctxt->context->node == NULL) return(NULL);
7962 switch (ctxt->context->node->type) {
7977 if (ctxt->context->node->parent == NULL)
7978 return((xmlNodePtr) ctxt->context->doc);
7979 if ((ctxt->context->node->parent->type == XML_ELEMENT_NODE) &&
7980 ((ctxt->context->node->parent->name[0] == ' ') ||
7981 (xmlStrEqual(ctxt->context->node->parent->name,
7984 return(ctxt->context->node->parent);
7986 xmlAttrPtr tmp = (xmlAttrPtr) ctxt->context->node;
7999 xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
8010 if (cur == ctxt->context->doc->children)
8011 return((xmlNodePtr) ctxt->context->doc);
8012 if (cur == (xmlNodePtr) ctxt->context->doc)
8038 xmlAttrPtr att = (xmlAttrPtr) ctxt->context->node;
8043 xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
8065 * @ctxt: the XPath Parser context
8077 xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8078 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8080 return(ctxt->context->node);
8081 return(xmlXPathNextAncestor(ctxt, cur));
8086 * @ctxt: the XPath Parser context
8096 xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8097 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8098 if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
8099 (ctxt->context->node->type == XML_NAMESPACE_DECL))
8101 if (cur == (xmlNodePtr) ctxt->context->doc)
8104 return(ctxt->context->node->next);
8110 * @ctxt: the XPath Parser context
8121 xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8122 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8123 if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
8124 (ctxt->context->node->type == XML_NAMESPACE_DECL))
8126 if (cur == (xmlNodePtr) ctxt->context->doc)
8129 return(ctxt->context->node->prev);
8133 return(ctxt->context->node->prev);
8140 * @ctxt: the XPath Parser context
8152 xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8153 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8159 cur = ctxt->context->node;
8170 if (cur == (xmlNodePtr) ctxt->context->doc) return(NULL);
8203 * @ctxt: the XPath Parser context
8215 xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur)
8217 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8219 cur = ctxt->context->node;
8238 if (cur == ctxt->context->doc->children)
8240 } while (xmlXPathIsAncestor(cur, ctxt->context->node));
8246 * @ctxt: the XPath Parser context
8255 * state kept in the parser context: ctxt->ancestor.
8260 xmlXPathNextPrecedingInternal(xmlXPathParserContextPtr ctxt,
8263 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8265 cur = ctxt->context->node;
8270 ctxt->ancestor = cur->parent;
8278 if (cur == ctxt->context->doc->children)
8280 if (cur != ctxt->ancestor)
8282 ctxt->ancestor = cur->parent;
8292 * @ctxt: the XPath Parser context
8305 xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8306 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8307 if (ctxt->context->node->type != XML_ELEMENT_NODE) return(NULL);
8308 if (ctxt->context->tmpNsList == NULL && cur != (xmlNodePtr) xmlXPathXMLNamespace) {
8309 if (ctxt->context->tmpNsList != NULL)
8310 xmlFree(ctxt->context->tmpNsList);
8311 ctxt->context->tmpNsList =
8312 xmlGetNsList(ctxt->context->doc, ctxt->context->node);
8313 ctxt->context->tmpNsNr = 0;
8314 if (ctxt->context->tmpNsList != NULL) {
8315 while (ctxt->context->tmpNsList[ctxt->context->tmpNsNr] != NULL) {
8316 ctxt->context->tmpNsNr++;
8321 if (ctxt->context->tmpNsNr > 0) {
8322 return (xmlNodePtr)ctxt->context->tmpNsList[--ctxt->context->tmpNsNr];
8324 if (ctxt->context->tmpNsList != NULL)
8325 xmlFree(ctxt->context->tmpNsList);
8326 ctxt->context->tmpNsList = NULL;
8333 * @ctxt: the XPath Parser context
8342 xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
8343 if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
8344 if (ctxt->context->node == NULL)
8346 if (ctxt->context->node->type != XML_ELEMENT_NODE)
8349 if (ctxt->context->node == (xmlNodePtr) ctxt->context->doc)
8351 return((xmlNodePtr)ctxt->context->node->properties);
8373 * @ctxt: the XPath Parser context
8378 xmlXPathRoot(xmlXPathParserContextPtr ctxt) {
8379 if ((ctxt == NULL) || (ctxt->context == NULL))
8381 ctxt->context->node = (xmlNodePtr) ctxt->context->doc;
8382 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8383 ctxt->context->node));
8396 * @ctxt: the XPath Parser context
8404 xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8406 if (ctxt->context->contextSize >= 0) {
8407 valuePush(ctxt,
8408 xmlXPathCacheNewFloat(ctxt->context,
8409 (double) ctxt->context->contextSize));
8412 "last() : %d\n", ctxt->context->contextSize);
8421 * @ctxt: the XPath Parser context
8431 xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8433 if (ctxt->context->proximityPosition >= 0) {
8434 valuePush(ctxt,
8435 xmlXPathCacheNewFloat(ctxt->context,
8436 (double) ctxt->context->proximityPosition));
8439 ctxt->context->proximityPosition);
8448 * @ctxt: the XPath Parser context
8455 xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8459 if ((ctxt->value == NULL) ||
8460 ((ctxt->value->type != XPATH_NODESET) &&
8461 (ctxt->value->type != XPATH_XSLT_TREE)))
8463 cur = valuePop(ctxt);
8466 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0));
8468 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context,
8473 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0));
8486 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) i));
8489 xmlXPathReleaseObject(ctxt->context, cur);
8551 * @ctxt: the XPath Parser context
8568 xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8574 obj = valuePop(ctxt);
8584 * ctxt, so the object is in a corrupt state.
8591 ns = xmlXPathGetElementsByIds(ctxt->context->doc, tokens);
8598 xmlXPathReleaseObject(ctxt->context, obj);
8599 valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, ret));
8602 obj = xmlXPathCacheConvertString(ctxt->context, obj);
8603 ret = xmlXPathGetElementsByIds(ctxt->context->doc, obj->stringval);
8604 valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, ret));
8605 xmlXPathReleaseObject(ctxt->context, obj);
8611 * @ctxt: the XPath Parser context
8623 xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8626 if (ctxt == NULL) return;
8629 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8630 ctxt->context->node));
8635 if ((ctxt->value == NULL) ||
8636 ((ctxt->value->type != XPATH_NODESET) &&
8637 (ctxt->value->type != XPATH_XSLT_TREE)))
8639 cur = valuePop(ctxt);
8642 valuePush(ctxtctxt->context, ""));
8650 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8652 valuePush(ctxt,
8653 xmlXPathCacheNewString(ctxt->context,
8657 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
8661 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8664 xmlXPathReleaseObject(ctxt->context, cur);
8669 * @ctxt: the XPath Parser context
8682 xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8685 if (ctxt == NULL) return;
8688 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8689 ctxt->context->node));
8693 if ((ctxt->value == NULL) ||
8694 ((ctxt->value->type != XPATH_NODESET) &&
8695 (ctxt->value->type != XPATH_XSLT_TREE)))
8697 cur = valuePop(ctxt);
8700 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8707 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8709 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
8713 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8716 xmlXPathReleaseObject(ctxt->context, cur);
8721 * @ctxt: the XPath Parser context
8742 xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs)
8747 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8748 ctxt->context->node));
8753 if ((ctxt->value == NULL) ||
8754 ((ctxt->value->type != XPATH_NODESET) &&
8755 (ctxt->value->type != XPATH_XSLT_TREE)))
8757 cur = valuePop(ctxt);
8760 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
8768 valuePush(ctxt,
8769 xmlXPathCacheNewCString(ctxt->context, ""));
8772 valuePush(ctxt,
8773 xmlXPathCacheNewString(ctxt->context,
8786 valuePush(ctxt, xmlXPathCacheWrapString(
8787 ctxt->context, fullname));
8791 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
8793 xmlXPathLocalNameFunction(ctxt, 1);
8796 xmlXPathReleaseObject(ctxt->context, cur);
8802 * @ctxt: the XPath Parser context
8837 xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8840 if (ctxt == NULL) return;
8842 valuePush(ctxt,
8843 xmlXPathCacheWrapString(ctxt->context,
8844 xmlXPathCastNodeToString(ctxt->context->node)));
8849 cur = valuePop(ctxt);
8851 valuePush(ctxt, xmlXPathCacheConvertString(ctxt->context, cur));
8856 * @ctxt: the XPath Parser context
8867 xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8871 if ((ctxt == NULL) || (ctxt->context == NULL))
8873 if (ctxt->context->node == NULL) {
8874 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, 0));
8878 content = xmlXPathCastNodeToString(ctxt->context->node);
8879 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context,
8888 cur = valuePop(ctxt);
8889 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context,
8891 xmlXPathReleaseObject(ctxt->context, cur);
8896 * @ctxt: the XPath Parser context
8904 xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8908 if (ctxt == NULL) return;
8914 cur = valuePop(ctxt);
8916 xmlXPathReleaseObject(ctxt->context, cur);
8923 newobj = valuePop(ctxt);
8925 xmlXPathReleaseObject(ctxt->context, newobj);
8926 xmlXPathReleaseObject(ctxt->context, cur);
8932 xmlXPathReleaseObject(ctxt->context, newobj);
8935 valuePush(ctxt, cur);
8940 * @ctxt: the XPath Parser context
8949 xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8955 needle = valuePop(ctxt);
8957 hay = valuePop(ctxt);
8960 xmlXPathReleaseObject(ctxt->context, hay);
8961 xmlXPathReleaseObject(ctxt->context, needle);
8965 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 1));
8967 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 0));
8968 xmlXPathReleaseObject(ctxt->context, hay);
8969 xmlXPathReleaseObject(ctxt->context, needle);
8974 * @ctxt: the XPath Parser context
8983 xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs) {
8990 needle = valuePop(ctxt);
8992 hay = valuePop(ctxt);
8995 xmlXPathReleaseObject(ctxt->context, hay);
8996 xmlXPathReleaseObject(ctxt->context, needle);
9001 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 0));
9003 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 1));
9004 xmlXPathReleaseObject(ctxt->context, hay);
9005 xmlXPathReleaseObject(ctxt->context, needle);
9010 * @ctxt: the XPath Parser context
9037 xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9055 len = valuePop(ctxt);
9057 xmlXPathReleaseObject(ctxt->context, len);
9062 start = valuePop(ctxt);
9064 xmlXPathReleaseObject(ctxt->context, start);
9067 str = valuePop(ctxt);
9124 valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
9126 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, ret));
9129 xmlXPathReleaseObject(ctxt->context, str);
9134 * @ctxt: the XPath Parser context
9146 xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9155 find = valuePop(ctxt);
9157 str = valuePop(ctxt);
9166 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
9170 xmlXPathReleaseObject(ctxt->context, str);
9171 xmlXPathReleaseObject(ctxt->context, find);
9176 * @ctxt: the XPath Parser context
9189 xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9198 find = valuePop(ctxt);
9200 str = valuePop(ctxt);
9210 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
9214 xmlXPathReleaseObject(ctxt->context, str);
9215 xmlXPathReleaseObject(ctxt->context, find);
9220 * @ctxt: the XPath Parser context
9233 xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9239 if (ctxt == NULL) return;
9242 valuePush(ctxt,
9243 xmlXPathCacheWrapString(ctxt->context,
9244 xmlXPathCastNodeToString(ctxt->context->node)));
9251 obj = valuePop(ctxt);
9275 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
9279 xmlXPathReleaseObject(ctxt->context, obj);
9284 * @ctxt: the XPath Parser context
9304 xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9317 to = valuePop(ctxt);
9319 from = valuePop(ctxt);
9321 str = valuePop(ctxt);
9360 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
9363 xmlXPathReleaseObject(ctxt->context, str);
9364 xmlXPathReleaseObject(ctxt->context, from);
9365 xmlXPathReleaseObject(ctxt->context, to);
9370 * @ctxt: the XPath Parser context
9382 xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9386 cur = valuePop(ctxt);
9388 cur = xmlXPathCacheConvertBoolean(ctxt->context, cur);
9389 valuePush(ctxt, cur);
9394 * @ctxt: the XPath Parser context
9403 xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9407 ctxt->value->boolval = ! ctxt->value->boolval;
9412 * @ctxt: the XPath Parser context
9419 xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9421 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 1));
9426 * @ctxt: the XPath Parser context
9433 xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9435 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, 0));
9440 * @ctxt: the XPath Parser context
9460 xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9470 val = valuePop(ctxt);
9472 theLang = xmlNodeGetLang(ctxt->context->node);
9484 xmlXPathReleaseObject(ctxt->context, val);
9485 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, ret));
9490 * @ctxt: the XPath Parser context
9497 xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9501 if (ctxt == NULL) return;
9503 if (ctxt->context->node == NULL) {
9504 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, 0.0));
9506 xmlChar* content = xmlNodeGetContent(ctxt->context->node);
9509 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, res));
9516 cur = valuePop(ctxt);
9517 valuePush(ctxt, xmlXPathCacheConvertNumber(ctxt->context, cur));
9522 * @ctxt: the XPath Parser context
9531 xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9537 if ((ctxt->value == NULL) ||
9538 ((ctxt->value->type != XPATH_NODESET) &&
9539 (ctxt->value->type != XPATH_XSLT_TREE)))
9541 cur = valuePop(ctxt);
9548 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, res));
9549 xmlXPathReleaseObject(ctxt->context, cur);
9566 * @ctxt: the XPath Parser context
9575 xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9582 XTRUNC(f, ctxt->value->floatval);
9583 if (f != ctxt->value->floatval) {
9584 if (ctxt->value->floatval > 0)
9585 ctxt->value->floatval = f;
9587 ctxt->value->floatval = f - 1;
9593 * @ctxt: the XPath Parser context
9602 xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9610 ctxt->value->floatval = ceil(ctxt->value->floatval);
9612 XTRUNC(f, ctxt->value->floatval);
9613 if (f != ctxt->value->floatval) {
9614 if (ctxt->value->floatval > 0)
9615 ctxt->value->floatval = f + 1;
9617 if (ctxt->value->floatval < 0 && f == 0)
9618 ctxt->value->floatval = xmlXPathNZERO;
9620 ctxt->value->floatval = f;
9629 * @ctxt: the XPath Parser context
9639 xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs) {
9646 if ((xmlXPathIsNaN(ctxt->value->floatval)) ||
9647 (xmlXPathIsInf(ctxt->value->floatval) == 1) ||
9648 (xmlXPathIsInf(ctxt->value->floatval) == -1) ||
9649 (ctxt->value->floatval == 0.0))
9652 XTRUNC(f, ctxt->value->floatval);
9653 if (ctxt->value->floatval < 0) {
9654 if (ctxt->value->floatval < f - 0.5)
9655 ctxt->value->floatval = f - 1;
9657 ctxt->value->floatval = f;
9658 if (ctxt->value->floatval == 0)
9659 ctxt->value->floatval = xmlXPathNZERO;
9661 if (ctxt->value->floatval < f + 0.5)
9662 ctxt->value->floatval = f;
9664 ctxt->value->floatval = f + 1;
9678 static void xmlXPathCompileExpr(xmlXPathParserContextPtr ctxt, int sort);
9679 static void xmlXPathCompPredicate(xmlXPathParserContextPtr ctxt, int filter);
9680 static void xmlXPathCompLocationPath(xmlXPathParserContextPtr ctxt);
9681 static void xmlXPathCompRelativeLocationPath(xmlXPathParserContextPtr ctxt);
9682 static xmlChar * xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt,
9687 * @ctxt: the XPath parser context
9698 xmlXPathCurrentChar(xmlXPathParserContextPtr ctxt, int *len) {
9703 if (ctxt == NULL)
9705 cur = ctxt->cur;
9772 * @ctxt: the XPath Parser context
9785 xmlXPathParseNCName(xmlXPathParserContextPtr ctxt) {
9790 if ((ctxt == NULL) || (ctxt->cur == NULL)) return(NULL);
9794 in = ctxt->cur;
9808 count = in - ctxt->cur;
9811 ret = xmlStrndup(ctxt->cur, count);
9812 ctxt->cur = in;
9816 return(xmlXPathParseNameComplex(ctxt, 0));
9822 * @ctxt: the XPath Parser context
9838 xmlXPathParseQName(xmlXPathParserContextPtr ctxt, xmlChar **prefix) {
9842 ret = xmlXPathParseNCName(ctxt);
9846 ret = xmlXPathParseNCName(ctxt);
9853 * @ctxt: the XPath Parser context
9866 xmlXPathParseName(xmlXPathParserContextPtr ctxt) {
9871 if ((ctxt == NULL) || (ctxt->cur == NULL)) return(NULL);
9875 in = ctxt->cur;
9887 count = in - ctxt->cur;
9888 ret = xmlStrndup(ctxt->cur, count);
9889 ctxt->cur = in;
9893 return(xmlXPathParseNameComplex(ctxt, 1));
9897 xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {
10081 * @ctxt: the XPath Parser context
10091 xmlXPathCompNumber(xmlXPathParserContextPtr ctxt)
10164 xmlXPathCacheNewFloat(ctxt->context, ret), NULL);
10169 * @ctxt: the XPath Parser context
10179 xmlXPathParseLiteral(xmlXPathParserContextPtr ctxt) {
10213 * @ctxt: the XPath Parser context
10223 xmlXPathCompLiteral(xmlXPathParserContextPtr ctxt) {
10254 xmlXPathCacheNewString(ctxt->context, ret), NULL);
10260 * @ctxt: the XPath Parser context
10276 xmlXPathCompVariableReference(xmlXPathParserContextPtr ctxt) {
10285 name = xmlXPathParseQName(ctxt, &prefix);
10289 ctxt->comp->last = -1;
10293 if ((ctxt->context != NULL) && (ctxt->context->flags & XML_XPATH_NOVAR)) {
10329 * @ctxt: the XPath Parser context
10338 xmlXPathCompFunctionCall(xmlXPathParserContextPtr ctxt) {
10344 name = xmlXPathParseQName(ctxt, &prefix);
10373 ctxt->comp->last = -1;
10376 int op1 = ctxt->comp->last;
10377 ctxt->comp->last = -1;
10378 xmlXPathCompileExpr(ctxt, sort);
10379 if (ctxt->error != XPATH_EXPRESSION_OK) {
10384 PUSH_BINARY_EXPR(XPATH_OP_ARG, op1, ctxt->comp->last, 0, 0);
10402 * @ctxt: the XPath Parser context
10413 xmlXPathCompPrimaryExpr(xmlXPathParserContextPtr ctxt) {
10415 if (CUR == '$') xmlXPathCompVariableReference(ctxt);
10419 xmlXPathCompileExpr(ctxt, 1);
10427 xmlXPathCompNumber(ctxt);
10429 xmlXPathCompLiteral(ctxt);
10431 xmlXPathCompFunctionCall(ctxt);
10438 * @ctxt: the XPath Parser context
10452 xmlXPathCompFilterExpr(xmlXPathParserContextPtr ctxt) {
10453 xmlXPathCompPrimaryExpr(ctxt);
10458 xmlXPathCompPredicate(ctxt, 1);
10467 * @ctxt: the XPath Parser context
10483 xmlXPathScanName(xmlXPathParserContextPtr ctxt) {
10489 cur = ctxt->cur;
10508 ret = xmlStrndup(cur, ctxt->cur - cur);
10509 ctxt->cur = cur;
10515 * @ctxt: the XPath Parser context
10532 xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
10567 name = xmlXPathScanName(ctxt);
10653 xmlXPathCompLocationPath(ctxt);
10655 xmlXPathCompFilterExpr(ctxt);
10663 PUSH_UNARY_EXPR(XPATH_OP_RESET, ctxt->comp->last, 1, 0);
10665 xmlXPathCompRelativeLocationPath(ctxt);
10667 xmlXPathCompRelativeLocationPath(ctxt);
10675 * @ctxt: the XPath Parser context
10684 xmlXPathCompUnionExpr(xmlXPathParserContextPtr ctxt) {
10685 xmlXPathCompPathExpr(ctxt);
10689 int op1 = ctxt->comp->last;
10694 xmlXPathCompPathExpr(ctxt);
10696 PUSH_BINARY_EXPR(XPATH_OP_UNION, op1, ctxt->comp->last, 0, 0);
10704 * @ctxt: the XPath Parser context
10713 xmlXPathCompUnaryExpr(xmlXPathParserContextPtr ctxt) {
10725 xmlXPathCompUnionExpr(ctxt);
10729 PUSH_UNARY_EXPR(XPATH_OP_PLUS, ctxt->comp->last, 2, 0);
10731 PUSH_UNARY_EXPR(XPATH_OP_PLUS, ctxt->comp->last, 3, 0);
10737 * @ctxt: the XPath Parser context
10749 xmlXPathCompMultiplicativeExpr(xmlXPathParserContextPtr ctxt) {
10750 xmlXPathCompUnaryExpr(ctxt);
10757 int op1 = ctxt->comp->last;
10770 xmlXPathCompUnaryExpr(ctxt);
10772 PUSH_BINARY_EXPR(XPATH_OP_MULT, op1, ctxt->comp->last, op, 0);
10779 * @ctxt: the XPath Parser context
10789 xmlXPathCompAdditiveExpr(xmlXPathParserContextPtr ctxt) {
10791 xmlXPathCompMultiplicativeExpr(ctxt);
10796 int op1 = ctxt->comp->last;
10802 xmlXPathCompMultiplicativeExpr(ctxt);
10804 PUSH_BINARY_EXPR(XPATH_OP_PLUS, op1, ctxt->comp->last, plus, 0);
10811 * @ctxt: the XPath Parser context
10828 xmlXPathCompRelationalExpr(xmlXPathParserContextPtr ctxt) {
10829 xmlXPathCompAdditiveExpr(ctxt);
10837 int op1 = ctxt->comp->last;
10846 xmlXPathCompAdditiveExpr(ctxt);
10848 PUSH_BINARY_EXPR(XPATH_OP_CMP, op1, ctxt->comp->last, inf, strict);
10855 * @ctxt: the XPath Parser context
10870 xmlXPathCompEqualityExpr(xmlXPathParserContextPtr ctxt) {
10871 xmlXPathCompRelationalExpr(ctxt);
10876 int op1 = ctxt->comp->last;
10883 xmlXPathCompRelationalExpr(ctxt);
10885 PUSH_BINARY_EXPR(XPATH_OP_EQUAL, op1, ctxt->comp->last, eq, 0);
10892 * @ctxt: the XPath Parser context
10901 xmlXPathCompAndExpr(xmlXPathParserContextPtr ctxt) {
10902 xmlXPathCompEqualityExpr(ctxt);
10906 int op1 = ctxt->comp->last;
10909 xmlXPathCompEqualityExpr(ctxt);
10911 PUSH_BINARY_EXPR(XPATH_OP_AND, op1, ctxt->comp->last, 0, 0);
10918 * @ctxt: the XPath Parser context
10927 xmlXPathCompileExpr(xmlXPathParserContextPtr ctxt, int sort) {
10928 xmlXPathCompAndExpr(ctxt);
10932 int op1 = ctxt->comp->last;
10935 xmlXPathCompAndExpr(ctxt);
10937 PUSH_BINARY_EXPR(XPATH_OP_OR, op1, ctxt->comp->last, 0, 0);
10940 if ((sort) && (ctxt->comp->steps[ctxt->comp->last].op != XPATH_OP_VALUE)) {
10947 PUSH_UNARY_EXPR(XPATH_OP_SORT, ctxt->comp->last , 0, 0);
10953 * @ctxt: the XPath Parser context
10962 xmlXPathCompPredicate(xmlXPathParserContextPtr ctxt, int filter) {
10963 int op1 = ctxt->comp->last;
10972 ctxt->comp->last = -1;
10983 xmlXPathCompileExpr(ctxt, 0);
10985 xmlXPathCompileExpr(ctxt, 1);
10993 PUSH_BINARY_EXPR(XPATH_OP_FILTER, op1, ctxt->comp->last, 0, 0);
10995 PUSH_BINARY_EXPR(XPATH_OP_PREDICATE, op1, ctxt->comp->last, 0, 0);
11003 * @ctxt: the XPath Parser context
11023 xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
11047 name = xmlXPathParseNCName(ctxt);
11084 name = xmlXPathParseLiteral(ctxt);
11110 *prefix = xmlXPathNsLookup(ctxt->context, name);
11129 name = xmlXPathParseNCName(ctxt);
11207 * @ctxt: the XPath Parser context
11238 xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
11265 if (ctxt->xptr) {
11266 name = xmlXPathParseNCName(ctxt);
11268 op2 = ctxt->comp->last;
11277 xmlXPathCompileExpr(ctxt, 1);
11278 /* PUSH_BINARY_EXPR(XPATH_OP_RANGETO, op2, ctxt->comp->last, 0, 0); */
11295 name = xmlXPathParseNCName(ctxt);
11319 if (ctxt->error != XPATH_EXPRESSION_OK) {
11324 name = xmlXPathCompNodeTest(ctxt, &test, &type, &prefix, name);
11328 if ((prefix != NULL) && (ctxt->context != NULL) &&
11329 (ctxt->context->flags & XML_XPATH_CHECKNS)) {
11330 if (xmlXPathNsLookup(ctxt->context, prefix) == NULL) {
11331 xmlXPathErr(ctxt, XPATH_UNDEF_PREFIX_ERROR);
11341 if (ctxt->value == NULL)
11343 else if (ctxt->value->nodesetval == NULL)
11346 xmlGenericErrorContextNodeSet(stdout, ctxt->value->nodesetval);
11352 op1 = ctxt->comp->last;
11353 ctxt->comp->last = -1;
11357 xmlXPathCompPredicate(ctxt, 0);
11365 PUSH_FULL_EXPR(XPATH_OP_COLLECT, op1, ctxt->comp->last, axis,
11371 if (ctxt->value == NULL)
11373 else if (ctxt->value->nodesetval == NULL)
11377 ctxt->value->nodesetval);
11383 * @ctxt: the XPath Parser context
11394 (xmlXPathParserContextPtr ctxt) {
11405 xmlXPathCompStep(ctxt);
11414 xmlXPathCompStep(ctxt);
11418 xmlXPathCompStep(ctxt);
11426 * @ctxt: the XPath Parser context
11446 xmlXPathCompLocationPath(xmlXPathParserContextPtr ctxt) {
11449 xmlXPathCompRelativeLocationPath(ctxt);
11457 xmlXPathCompRelativeLocationPath(ctxt);
11464 xmlXPathCompRelativeLocationPath(ctxt);
11478 xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op);
11568 xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt,
11575 xmlXPathCompExprPtr comp = ctxt->comp;
11584 contextSize = xmlXPathCompOpEvalPredicate(ctxt,
11591 xmlXPathContextPtr xpctxt = ctxt->context;
11633 exprOp = &ctxt->comp->steps[op->ch2];
11662 valuePush(ctxt, contextObj);
11664 res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1);
11666 if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) {
11682 if (ctxt->value == contextObj) {
11688 valuePop(ctxt);
11700 if (ctxt->value == contextObj)
11701 valuePop(ctxt);
11706 xmlXPathReleaseObject(ctxt->context, exprRes);
11720 xmlXPathCompOpEvalPositionalPredicate(xmlXPathParserContextPtr ctxt,
11729 xmlXPathCompExprPtr comp = ctxt->comp;
11735 contextSize = xmlXPathCompOpEvalPredicate(ctxt,
11760 xmlXPathContextPtr xpctxt = ctxt->context;
11779 exprOp = &ctxt->comp->steps[op->ch2];
11810 frame = xmlXPathSetFrame(ctxt);
11811 valuePush(ctxt, contextObj);
11812 res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1);
11813 tmp = valuePop(ctxt);
11814 xmlXPathPopFrame(ctxt, frame);
11816 if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) {
11823 tmp = valuePop(ctxt);
11828 valuePush(ctxt, tmp);
11870 xmlXPathReleaseObject(ctxt->context, exprRes);
11873 if (ctxt->value == contextObj) {
11879 valuePop(ctxt);
11897 if (ctxt->value == contextObj)
11898 valuePop(ctxt);
11902 xmlXPathReleaseObject(ctxt->context, exprRes);
11916 xmlXPathIsPositionalPredicate(xmlXPathParserContextPtr ctxt,
11940 exprOp = &ctxt->comp->steps[op->ch2];
11971 xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
12037 xmlXPathContextPtr xpctxt = ctxt->context;
12041 obj = valuePop(ctxt);
12155 valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, NULL));
12184 predOp = &ctxt->comp->steps[op->ch2];
12185 if (xmlXPathIsPositionalPredicate(ctxt, predOp, &maxPos)) {
12190 predOp = &ctxt->comp->steps[predOp->ch1];
12260 cur = next(ctxt, cur);
12493 * (E.g. ctxt->value->type == XPATH_LOCATIONSET)
12517 newSize = xmlXPathCompOpEvalPositionalPredicate(ctxt,
12520 newSize = xmlXPathCompOpEvalPredicate(ctxt,
12523 if (ctxt->error != XPATH_EXPRESSION_OK) {
12579 ctxt->value->boolval = 1;
12580 ctxt->value->user = obj->user;
12603 valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, outSeq));
12619 xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
12624 * @ctxt: the XPath parser context with the compiled expression
12634 xmlXPathCompOpEvalFirst(xmlXPathParserContextPtr ctxt,
12642 comp = ctxt->comp;
12648 xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch1],
12651 if ((ctxt->value != NULL)
12652 && (ctxt->value->type == XPATH_NODESET)
12653 && (ctxt->value->nodesetval != NULL)
12654 && (ctxt->value->nodesetval->nodeNr >= 1)) {
12665 if (ctxt->value->nodesetval->nodeNr > 1)
12666 xmlXPathNodeSetSort(ctxt->value->nodesetval);
12667 *first = ctxt->value->nodesetval->nodeTab[0];
12670 xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch2],
12674 arg2 = valuePop(ctxt);
12677 arg1 = valuePop(ctxt);
12681 valuePush(ctxt, arg1);
12682 xmlXPathReleaseObject(ctxt->context, arg2);
12688 xmlXPathRoot(ctxt);
12692 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12695 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12697 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
12698 ctxt->context->node));
12702 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12705 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12707 ctxt->context->node = NULL;
12713 total = xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12716 total += xmlXPathNodeCollectAndTest(ctxt, op, first, NULL, 0);
12720 valuePush(ctxt,
12721 xmlXPathCacheObjectCopy(ctxt->context,
12727 xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch1],
12730 if ((ctxt->value != NULL)
12731 && (ctxt->value->type == XPATH_NODESET)
12732 && (ctxt->value->nodesetval != NULL)
12733 && (ctxt->value->nodesetval->nodeNr > 1))
12734 xmlXPathNodeSetSort(ctxt->value->nodesetval);
12738 total += xmlXPathCompOpEvalFilterFirst(ctxt, op, first);
12742 return (xmlXPathCompOpEval(ctxt, op));
12748 * @ctxt: the XPath parser context with the compiled expression
12758 xmlXPathCompOpEvalLast(xmlXPathParserContextPtr ctxt
12770 comp = ctxt->comp;
12775 bakd = ctxt->context->doc;
12776 bak = ctxt->context->node;
12777 pp = ctxt->context->proximityPosition;
12778 cs = ctxt->context->contextSize;
12780 xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch1], last);
12782 if ((ctxt->value != NULL)
12783 && (ctxt->value->type == XPATH_NODESET)
12784 && (ctxt->value->nodesetval != NULL)
12785 && (ctxt->value->nodesetval->nodeNr >= 1)) {
12789 if (ctxt->value->nodesetval->nodeNr > 1)
12790 xmlXPathNodeSetSort(ctxt->value->nodesetval);
12792 ctxt->value->nodesetval->nodeTab[ctxt->value->
12796 ctxt->context->doc = bakd;
12797 ctxt->context->node = bak;
12798 ctxt->context->proximityPosition = pp;
12799 ctxt->context->contextSize = cs;
12801 xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch2], last);
12803 if ((ctxt->value != NULL)
12804 && (ctxt->value->type == XPATH_NODESET)
12805 && (ctxt->value->nodesetval != NULL)
12806 && (ctxt->value->nodesetval->nodeNr >= 1)) { /* TODO: NOP ? */
12809 arg2 = valuePop(ctxt);
12812 arg1 = valuePop(ctxt);
12816 valuePush(ctxt, arg1);
12817 xmlXPathReleaseObject(ctxt->context, arg2);
12823 xmlXPathRoot(ctxt);
12827 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12830 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12832 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
12833 ctxt->context->node));
12837 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12840 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12842 ctxt->context->node = NULL;
12848 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12851 total += xmlXPathNodeCollectAndTest(ctxt, op, NULL, last, 0);
12855 valuePush(ctxt,
12856 xmlXPathCacheObjectCopy(ctxt->context,
12862 xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch1],
12865 if ((ctxt->value != NULL)
12866 && (ctxt->value->type == XPATH_NODESET)
12867 && (ctxt->value->nodesetval != NULL)
12868 && (ctxt->value->nodesetval->nodeNr > 1))
12869 xmlXPathNodeSetSort(ctxt->value->nodesetval);
12872 return (xmlXPathCompOpEval(ctxt, op));
12878 xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
12891 comp = ctxt->comp;
12910 xmlXPathCompOpEvalLast(ctxt,
12918 if ((ctxt->value != NULL) &&
12919 (ctxt->value->type == XPATH_NODESET) &&
12920 (ctxt->value->nodesetval != NULL) &&
12921 (ctxt->value->nodesetval->nodeTab != NULL) &&
12922 (ctxt->value->nodesetval->nodeNr > 1)) {
12923 ctxt->value->nodesetval->nodeTab[0] =
12924 ctxt->value->nodesetval->nodeTab[ctxt->
12929 ctxt->value->nodesetval->nodeNr = 1;
12930 *first = *(ctxt->value->nodesetval->nodeTab);
12937 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
12941 if (ctxt->value == NULL)
12945 oldnode = ctxt->context->node;
12949 if (ctxt->value->type == XPATH_LOCATIONSET) {
12960 obj = valuePop(ctxt);
12962 ctxt->context->node = NULL;
12965 ctxt->context->contextSize = 0;
12966 ctxt->context->proximityPosition = 0;
12968 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12969 res = valuePop(ctxt);
12971 xmlXPathReleaseObject(ctxt->context, res);
12973 valuePush(ctxt, obj);
12984 ctxt->context->node = oldlocset->locTab[i]->user;
12985 ctxt->context->contextSize = oldlocset->locNr;
12986 ctxt->context->proximityPosition = i + 1;
12988 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
12989 ctxt->context->node);
12992 ctxt->context->node);
12994 valuePush(ctxt, tmp);
12996 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
12997 if (ctxt->error != XPATH_EXPRESSION_OK) {
13005 res = valuePop(ctxt);
13006 if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
13008 xmlXPathCacheObjectCopy(ctxt->context,
13015 xmlXPathReleaseObject(ctxt->context, res);
13017 if (ctxt->value == tmp) {
13018 valuePop(ctxt);
13027 ctxt->context->node = NULL;
13037 xmlXPathReleaseObject(ctxt->context, tmp);
13042 xmlXPathReleaseObject(ctxt->context, obj);
13043 ctxt->context->node = NULL;
13044 ctxt->context->contextSize = -1;
13045 ctxt->context->proximityPosition = -1;
13046 valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
13047 ctxt->context->node = oldnode;
13058 obj = valuePop(ctxt);
13061 oldnode = ctxt->context->node;
13062 oldDoc = ctxt->context->doc;
13063 ctxt->context->node = NULL;
13066 ctxt->context->contextSize = 0;
13067 ctxt->context->proximityPosition = 0;
13071 xmlXPathCompOpEval(ctxt,
13074 res = valuePop(ctxt);
13078 valuePush(ctxt, obj);
13079 ctxt->context->node = oldnode;
13097 ctxt->context->node = oldset->nodeTab[i];
13100 ctxt->context->doc = oldset->nodeTab[i]->doc;
13102 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
13103 ctxt->context->node);
13106 ctxt->context->node);
13108 valuePush(ctxt, tmp);
13109 ctxt->context->contextSize = oldset->nodeNr;
13110 ctxt->context->proximityPosition = i + 1;
13112 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13113 if (ctxt->error != XPATH_EXPRESSION_OK) {
13122 res = valuePop(ctxt);
13123 if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
13130 xmlXPathReleaseObject(ctxt->context, res);
13132 if (ctxt->value == tmp) {
13133 valuePop(ctxt);
13142 ctxt->context->node = NULL;
13152 xmlXPathReleaseObject(ctxt->context, tmp);
13157 xmlXPathReleaseObject(ctxt->context, obj);
13158 ctxt->context->node = NULL;
13159 ctxt->context->contextSize = -1;
13160 ctxt->context->proximityPosition = -1;
13162 ctxt->context->doc = oldDoc;
13163 valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, newset));
13165 ctxt->context->node = oldnode;
13172 * @ctxt: the XPath parser context with the compiled expression
13179 xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
13191 comp = ctxt->comp;
13196 bakd = ctxt->context->doc;
13197 bak = ctxt->context->node;
13198 pp = ctxt->context->proximityPosition;
13199 cs = ctxt->context->contextSize;
13200 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13202 xmlXPathBooleanFunction(ctxt, 1);
13203 if ((ctxt->value == NULL) || (ctxt->value->boolval == 0))
13205 arg2 = valuePop(ctxt);
13206 ctxt->context->doc = bakd;
13207 ctxt->context->node = bak;
13208 ctxt->context->proximityPosition = pp;
13209 ctxt->context->contextSize = cs;
13210 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13211 if (ctxt->error) {
13215 xmlXPathBooleanFunction(ctxt, 1);
13216 arg1 = valuePop(ctxt);
13218 valuePush(ctxt, arg1);
13219 xmlXPathReleaseObject(ctxt->context, arg2);
13222 bakd = ctxt->context->doc;
13223 bak = ctxt->context->node;
13224 pp = ctxt->context->proximityPosition;
13225 cs = ctxt->context->contextSize;
13226 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13228 xmlXPathBooleanFunction(ctxt, 1);
13229 if ((ctxt->value == NULL) || (ctxt->value->boolval == 1))
13231 arg2 = valuePop(ctxt);
13232 ctxt->context->doc = bakd;
13233 ctxt->context->node = bak;
13234 ctxt->context->proximityPosition = pp;
13235 ctxt->context->contextSize = cs;
13236 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13237 if (ctxt->error) {
13241 xmlXPathBooleanFunction(ctxt, 1);
13242 arg1 = valuePop(ctxt);
13244 valuePush(ctxt, arg1);
13245 xmlXPathReleaseObject(ctxt->context, arg2);
13248 bakd = ctxt->context->doc;
13249 bak = ctxt->context->node;
13250 pp = ctxt->context->proximityPosition;
13251 cs = ctxt->context->contextSize;
13252 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13254 ctxt->context->doc = bakd;
13255 ctxt->context->node = bak;
13256 ctxt->context->proximityPosition = pp;
13257 ctxt->context->contextSize = cs;
13258 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13261 equal = xmlXPathEqualValues(ctxt);
13263 equal = xmlXPathNotEqualValues(ctxt);
13264 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, equal));
13267 bakd = ctxt->context->doc;
13268 bak = ctxt->context->node;
13269 pp = ctxt->context->proximityPosition;
13270 cs = ctxt->context->contextSize;
13271 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13273 ctxt->context->doc = bakd;
13274 ctxt->context->node = bak;
13275 ctxt->context->proximityPosition = pp;
13276 ctxt->context->contextSize = cs;
13277 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13279 ret = xmlXPathCompareValues(ctxt, op->value, op->value2);
13280 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, ret));
13283 bakd = ctxt->context->doc;
13284 bak = ctxt->context->node;
13285 pp = ctxt->context->proximityPosition;
13286 cs = ctxt->context->contextSize;
13287 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
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]);
13298 xmlXPathSubValues(ctxt);
13300 xmlXPathAddValues(ctxt);
13302 xmlXPathValueFlipSign(ctxt);
13309 bakd = ctxt->context->doc;
13310 bak = ctxt->context->node;
13311 pp = ctxt->context->proximityPosition;
13312 cs = ctxt->context->contextSize;
13313 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13315 ctxt->context->doc = bakd;
13316 ctxt->context->node = bak;
13317 ctxt->context->proximityPosition = pp;
13318 ctxt->context->contextSize = cs;
13319 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13322 xmlXPathMultValues(ctxt);
13324 xmlXPathDivValues(ctxt);
13326 xmlXPathModValues(ctxt);
13329 bakd = ctxt->context->doc;
13330 bak = ctxt->context->node;
13331 pp = ctxt->context->proximityPosition;
13332 cs = ctxt->context->contextSize;
13333 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13335 ctxt->context->doc = bakd;
13336 ctxt->context->node = bak;
13337 ctxt->context->proximityPosition = pp;
13338 ctxt->context->contextSize = cs;
13339 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13342 arg2 = valuePop(ctxt);
13345 arg1 = valuePop(ctxt);
13355 valuePush(ctxt, arg1);
13356 xmlXPathReleaseObject(ctxt->context, arg2);
13359 xmlXPathRoot(ctxt);
13363 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13366 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13368 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
13369 ctxt->context->node));
13373 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13376 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13378 ctxt->context->node = NULL;
13384 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13387 total += xmlXPathNodeCollectAndTest(ctxt, op, NULL, NULL, 0);
13391 valuePush(ctxt,
13392 xmlXPathCacheObjectCopy(ctxt->context,
13400 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13402 val = xmlXPathVariableLookup(ctxt->context, op->value4);
13404 ctxt->error = XPATH_UNDEF_VARIABLE_ERROR;
13407 valuePush(ctxt, val);
13411 URI = xmlXPathNsLookup(ctxt->context, op->value5);
13416 ctxt->error = XPATH_UNDEF_PREFIX_ERROR;
13419 val = xmlXPathVariableLookupNS(ctxt->context,
13422 ctxt->error = XPATH_UNDEF_VARIABLE_ERROR;
13425 valuePush(ctxt, val);
13435 frame = xmlXPathSetFrame(ctxt);
13438 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13439 if (ctxt->valueNr < op->value) {
13442 ctxt->error = XPATH_INVALID_OPERAND;
13443 xmlXPathPopFrame(ctxt, frame);
13447 if (ctxt->valueTab[(ctxt->valueNr - 1) - i] == NULL) {
13450 ctxt->error = XPATH_INVALID_OPERAND;
13451 xmlXPathPopFrame(ctxt, frame);
13462 xmlXPathFunctionLookup(ctxt->context,
13465 URI = xmlXPathNsLookup(ctxt->context, op->value5);
13470 xmlXPathPopFrame(ctxt, frame);
13471 ctxt->error = XPATH_UNDEF_PREFIX_ERROR;
13474 func = xmlXPathFunctionLookupNS(ctxt->context,
13486 oldFunc = ctxt->context->function;
13487 oldFuncURI = ctxt->context->functionURI;
13488 ctxt->context->function = op->value4;
13489 ctxt->context->functionURI = op->cacheURI;
13490 func(ctxt, op->value);
13491 ctxt->context->function = oldFunc;
13492 ctxt->context->functionURI = oldFuncURI;
13493 xmlXPathPopFrame(ctxt, frame);
13497 bakd = ctxt->context->doc;
13498 bak = ctxt->context->node;
13499 pp = ctxt->context->proximityPosition;
13500 cs = ctxt->context->contextSize;
13502 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13503 ctxt->context->contextSize = cs;
13504 ctxt->context->proximityPosition = pp;
13505 ctxt->context->node = bak;
13506 ctxt->context->doc = bakd;
13509 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
13510 ctxt->context->doc = bakd;
13511 ctxt->context->node = bak;
13553 xmlXPathCompOpEvalFirst(ctxt,
13561 if ((ctxt->value != NULL) &&
13562 (ctxt->value->type == XPATH_NODESET) &&
13563 (ctxt->value->nodesetval != NULL) &&
13564 (ctxt->value->nodesetval->nodeNr > 1))
13565 ctxt->value->nodesetval->nodeNr = 1;
13587 xmlXPathCompOpEvalLast(ctxt,
13595 if ((ctxt->value != NULL) &&
13596 (ctxt->value->type == XPATH_NODESET) &&
13597 (ctxt->value->nodesetval != NULL) &&
13598 (ctxt->value->nodesetval->nodeTab != NULL) &&
13599 (ctxt->value->nodesetval->nodeNr > 1)) {
13600 ctxt->value->nodesetval->nodeTab[0] =
13601 ctxt->value->nodesetval->nodeTab[ctxt->
13606 ctxt->value->nodesetval->nodeNr = 1;
13624 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13628 if (ctxt->value == NULL)
13631 oldnode = ctxt->context->node;
13637 if (ctxt->value->type == XPATH_LOCATIONSET) {
13647 obj = valuePop(ctxt);
13649 ctxt->context->node = NULL;
13652 ctxt->context->contextSize = 0;
13653 ctxt->context->proximityPosition = 0;
13656 xmlXPathCompOpEval(ctxt,
13658 res = valuePop(ctxt);
13660 xmlXPathReleaseObject(ctxt->context, res);
13662 valuePush(ctxt, obj);
13673 ctxt->context->node = oldlocset->locTab[i]->user;
13674 ctxt->context->contextSize = oldlocset->locNr;
13675 ctxt->context->proximityPosition = i + 1;
13676 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
13677 ctxt->context->node);
13678 valuePush(ctxt, tmp);
13682 xmlXPathCompOpEval(ctxt,
13684 if (ctxt->error != XPATH_EXPRESSION_OK) {
13693 res = valuePop(ctxt);
13694 if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
13704 xmlXPathReleaseObject(ctxt->context, res);
13706 if (ctxt->value == tmp) {
13707 res = valuePop(ctxt);
13708 xmlXPathReleaseObject(ctxt->context, res);
13711 ctxt->context->node = NULL;
13717 xmlXPathReleaseObject(ctxt->context, obj);
13718 ctxt->context->node = NULL;
13719 ctxt->context->contextSize = -1;
13720 ctxt->context->proximityPosition = -1;
13721 valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
13722 ctxt->context->node = oldnode;
13733 obj = valuePop(ctxt);
13736 oldnode = ctxt->context->node;
13737 oldDoc = ctxt->context->doc;
13738 ctxt->context->node = NULL;
13741 ctxt->context->contextSize = 0;
13742 ctxt->context->proximityPosition = 0;
13746 xmlXPathCompOpEval(ctxt,
13749 res = valuePop(ctxt);
13753 valuePush(ctxt, obj);
13754 ctxt->context->node = oldnode;
13795 ctxt->context->node = oldset->nodeTab[i];
13798 ctxt->context->doc = oldset->nodeTab[i]->doc;
13800 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
13801 ctxt->context->node);
13804 ctxt->context->node);
13806 valuePush(ctxt, tmp);
13807 ctxt->context->contextSize = oldset->nodeNr;
13808 ctxt->context->proximityPosition = i + 1;
13816 xmlXPathCompOpEval(ctxt,
13818 if (ctxt->error != XPATH_EXPRESSION_OK) {
13832 res = valuePop(ctxt);
13833 if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
13841 xmlXPathReleaseObject(ctxt->context, res);
13843 if (ctxt->value == tmp) {
13844 valuePop(ctxt);
13853 ctxt->context->node = NULL;
13856 xmlXPathReleaseObject(ctxt->context, tmp);
13860 xmlXPathReleaseObject(ctxt->context, obj);
13861 ctxt->context->node = NULL;
13862 ctxt->context->contextSize = -1;
13863 ctxt->context->proximityPosition = -1;
13865 ctxt->context->doc = oldDoc;
13866 valuePush(ctxt,
13867 xmlXPathCacheWrapNodeSet(ctxt->context, newset));
13869 ctxt->context->node = oldnode;
13874 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13876 if ((ctxt->value != NULL) &&
13877 (ctxt->value->type == XPATH_NODESET) &&
13878 (ctxt->value->nodesetval != NULL) &&
13879 (ctxt->value->nodesetval->nodeNr > 1))
13881 xmlXPathNodeSetSort(ctxt->value->nodesetval);
13896 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
13900 if (ctxt->value->type == XPATH_LOCATIONSET) {
13907 obj = valuePop(ctxt);
13911 ctxt->context->node = NULL;
13912 ctxt->context->contextSize = 0;
13913 ctxt->context->proximityPosition = 0;
13914 total += xmlXPathCompOpEval(ctxt,&comp->steps[op->ch2]);
13915 res = valuePop(ctxt);
13917 xmlXPathReleaseObject(ctxt->context, res);
13919 valuePush(ctxt, obj);
13930 ctxt->context->node = oldlocset->locTab[i]->user;
13931 ctxt->context->contextSize = oldlocset->locNr;
13932 ctxt->context->proximityPosition = i + 1;
13933 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
13934 ctxt->context->node);
13935 valuePush(ctxt, tmp);
13939 xmlXPathCompOpEval(ctxt,
13941 if (ctxt->error != XPATH_EXPRESSION_OK) {
13946 res = valuePop(ctxt);
13972 xmlXPathReleaseObject(ctxt->context, res);
13974 if (ctxt->value == tmp) {
13975 res = valuePop(ctxt);
13976 xmlXPathReleaseObject(ctxt->context, res);
13979 ctxt->context->node = NULL;
13983 obj = valuePop(ctxt);
13985 ctxt->context->node = NULL;
13995 ctxt->context->node = oldset->nodeTab[i];
13999 tmp = xmlXPathCacheNewNodeSet(ctxt->context,
14000 ctxt->context->node);
14001 valuePush(ctxt, tmp);
14005 xmlXPathCompOpEval(ctxt,
14007 if (ctxt->error != XPATH_EXPRESSION_OK) {
14012 res = valuePop(ctxt);
14024 xmlXPathReleaseObject(ctxt->context, res);
14026 if (ctxt->value == tmp) {
14027 res = valuePop(ctxt);
14028 xmlXPathReleaseObject(ctxt->context, res);
14031 ctxt->context->node = NULL;
14039 xmlXPathReleaseObject(ctxt->context, obj);
14040 ctxt->context->node = NULL;
14041 ctxt->context->contextSize = -1;
14042 ctxt->context->proximityPosition = -1;
14043 valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
14050 ctxt->error = XPATH_INVALID_OPERAND;
14056 * @ctxt: the XPath parser context
14063 xmlXPathCompOpEvalToBoolean(xmlXPathParserContextPtr ctxt,
14070 /* comp = ctxt->comp; */
14077 return(xmlXPathEvaluatePredicateResult(ctxt, resObj));
14084 op = &ctxt->comp->steps[op->ch1];
14092 xmlXPathCompOpEval(ctxt, &ctxt->comp->steps[op->ch1]);
14093 if (ctxt->error != XPATH_EXPRESSION_OK)
14096 xmlXPathNodeCollectAndTest(ctxt, op, NULL, NULL, 1);
14097 if (ctxt->error != XPATH_EXPRESSION_OK)
14100 resObj = valuePop(ctxt);
14108 xmlXPathCompOpEval(ctxt, op);
14109 if (ctxt->error != XPATH_EXPRESSION_OK)
14112 resObj = valuePop(ctxt);
14132 res = xmlXPathEvaluatePredicateResult(ctxt, resObj);
14136 xmlXPathReleaseObject(ctxt->context, resObj);
14146 * @ctxt: the XPath parser context with the compiled expression
14151 xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp,
14163 if ((ctxt == NULL) || (comp == NULL))
14183 *resultSeq = xmlXPathCacheNewNodeSet(ctxt, NULL);
14197 (xmlNodePtr) ctxt->doc);
14202 xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, ctxt->node);
14210 cur = (xmlNodePtr)ctxt->doc;
14211 } else if (ctxt->node != NULL) {
14212 switch (ctxt->node->type) {
14220 cur = ctxt->node;
14374 * @ctxt: the XPath parser context with the compiled expression
14380 xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
14384 if ((ctxt == NULL) || (ctxt->comp == NULL))
14387 if (ctxt->valueTab == NULL) {
14389 ctxt->valueTab = (xmlXPathObjectPtr *)
14391 if (ctxt->valueTab == NULL) {
14392 xmlXPathPErrMemory(ctxt, "creating evaluation context\n");
14393 xmlFree(ctxt);
14395 ctxt->valueNr = 0;
14396 ctxt->valueMax = 10;
14397 ctxt->value = NULL;
14398 ctxt->valueFrame = 0;
14401 if (ctxt->comp->stream) {
14408 res = xmlXPathRunStreamEval(ctxt->context,
14409 ctxt->comp->stream, NULL, 1);
14418 res = xmlXPathRunStreamEval(ctxt->context,
14419 ctxt->comp->stream, &resObj, 0);
14422 valuePush(ctxt, resObj);
14426 xmlXPathReleaseObject(ctxt->context, resObj);
14434 comp = ctxt->comp;
14441 return(xmlXPathCompOpEvalToBoolean(ctxt,
14444 xmlXPathCompOpEval(ctxt, &comp->steps[comp->last]);
14457 * @ctxt: the XPath context
14472 xmlXPathEvalPredicate(xmlXPathContextPtr ctxt, xmlXPathObjectPtr res) {
14473 if ((ctxt == NULL) || (res == NULL)) return(0);
14478 return(res->floatval == ctxt->proximityPosition);
14495 * @ctxt: the XPath Parser context
14510 xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
14512 if ((ctxt == NULL) || (res == NULL)) return(0);
14518 return((res->floatval == ctxt->context->proximityPosition) &&
14521 return(res->floatval == ctxt->context->proximityPosition);
14547 * @ctxt: an XPath context
14555 xmlXPathTryStreamCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
14582 ((ctxt == NULL) || (ctxt->nsNr == 0) || (tmp[1] == ':')))
14585 if (ctxt != NULL) {
14586 dict = ctxt->dict;
14587 if (ctxt->nsNr > 0) {
14588 namespaces = xmlMalloc(2 * (ctxt->nsNr + 1) * sizeof(xmlChar*));
14590 xmlXPathErrMemory(ctxt, "allocating namespaces array\n");
14593 for (i = 0, j = 0; (j < ctxt->nsNr); j++) {
14594 ns = ctxt->namespaces[j];
14611 xmlXPathErrMemory(ctxt, "allocating streamable expression\n");
14681 * @ctxt: an XPath context
14690 xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
14695 comp = xmlXPathTryStreamCompile(ctxt, str);
14702 pctxt = xmlXPathNewParserContext(str, ctxt);
14762 * @ctxt: the XPath context
14774 xmlXPathContextPtr ctxt,
14784 CHECK_CTXT_NEG(ctxt)
14803 pctxt = xmlXPathCompParserContext(comp, ctxt);
14827 xmlXPathReleaseObject(ctxt, tmp);
14874 * @ctxt: the XPath context
14884 xmlXPathContextPtr ctxt)
14886 return(xmlXPathCompiledEvalInternal(comp, ctxt, NULL, 1));
14891 * @ctxt: the XPath Parser context
14897 xmlXPathEvalExpr(xmlXPathParserContextPtr ctxt) {
14902 if (ctxt == NULL) return;
14905 comp = xmlXPathTryStreamCompile(ctxt->context, ctxt->base);
14907 if (ctxt->comp != NULL)
14908 xmlXPathFreeCompExpr(ctxt->comp);
14909 ctxt->comp = comp;
14910 if (ctxt->cur != NULL)
14911 while (*ctxt->cur != 0) ctxt->cur++;
14915 xmlXPathCompileExpr(ctxt, 1);
14917 * In this scenario the expression string will sit in ctxt->base.
14919 if ((ctxt->error == XPATH_EXPRESSION_OK) &&
14920 (ctxt->comp != NULL) &&
14921 (ctxt->base != NULL) &&
14922 (ctxt->comp->nbStep > 2) &&
14923 (ctxt->comp->last >= 0) &&
14924 (xmlXPathCanRewriteDosExpression((xmlChar *) ctxt->base) == 1))
14926 xmlXPathRewriteDOSExpression(ctxt->comp,
14927 &ctxt->comp->steps[ctxt->comp->last]);
14931 xmlXPathRunEval(ctxt, 0);
14946 xmlXPathParserContextPtr ctxt;
14954 ctxt = xmlXPathNewParserContext(str, ctx);
14955 if (ctxt == NULL)
14957 xmlXPathEvalExpr(ctxt);
14959 if (ctxt->value == NULL) {
14963 } else if ((*ctxt->cur != 0) && (ctxt->comp != NULL)
14965 && (ctxt->comp->stream == NULL)
14968 xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_EXPR_ERROR);
14971 res = valuePop(ctxt);
14975 tmp = valuePop(ctxt);
14987 if (ctxt->error != XPATH_EXPRESSION_OK) {
14992 xmlXPathFreeParserContext(ctxt);
14999 * @ctxt: the XPath context
15007 xmlXPathEvalExpression(const xmlChar *str, xmlXPathContextPtr ctxt) {
15012 CHECK_CTXT(ctxt)
15016 pctxt = xmlXPathNewParserContext(str, ctxt);
15030 xmlXPathReleaseObject(ctxt, tmp);
15050 * @ctxt: the XPath Parser context
15097 xmlXPathEscapeUriFunction(xmlXPathParserContextPtr ctxt, int nargs) {
15106 escape_reserved = xmlXPathPopBoolean(ctxt);
15109 str = valuePop(ctxt);
15151 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
15154 xmlXPathReleaseObject(ctxt->context, str);
15159 * @ctxt: the XPath context
15164 xmlXPathRegisterAllFunctions(xmlXPathContextPtr ctxt)
15166 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"boolean",
15168 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"ceiling",
15170 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"count",
15172 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"concat",
15174 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"contains",
15176 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"id",
15178 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"false",
15180 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"floor",
15182 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"last",
15184 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"lang",
15186 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"local-name",
15188 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"not",
15190 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"name",
15192 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"namespace-uri",
15194 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"normalize-space",
15196 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"number",
15198 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"position",
15200 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"round",
15202 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"string",
15204 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"string-length",
15206 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"starts-with",
15208 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring",
15210 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring-before",
15212 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"substring-after",
15214 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"sum",
15216 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"true",
15218 xmlXPathRegisterFunc(ctxt, (const xmlChar *)"translate",
15221 xmlXPathRegisterFuncNS(ctxt, (const xmlChar *)"escape-uri",