Attached is a patch to ext/dom/php_domxml.c that adds the ability to set the context node when running xpath_eval(). xpath_eval() (and xpath_eval_expression()) can now accept and optional second parameter that is the context node. If no argument is specified, it works as before. This patch is against the head of the CVS tree. I also have a patch for the 4.0.6 version of this file for those who need/want it. BTW, has a decision been made about what interface to domxml will be in the next release of PHP? -- Paul Marquis [EMAIL PROTECTED]
Index: php_domxml.c =================================================================== RCS file: /repository/php4/ext/domxml/php_domxml.c,v retrieving revision 1.40 diff -u -r1.40 php_domxml.c --- php_domxml.c 8 Jul 2001 00:54:25 -0000 1.40 +++ php_domxml.c 10 Jul 2001 21:34:10 -0000 @@ -2456,19 +2456,37 @@ static void php_xpathptr_eval(INTERNAL_FUNCTION_PARAMETERS, int mode, int expr) { - zval *id, *str, *rv; + zval *id, *str, *contextnode, *rv; xmlXPathContextPtr ctxp; xmlXPathObjectPtr xpathobjp; + xmlNode *contextnodep; int ret; - if (ZEND_NUM_ARGS() != 1 || getParameters(ht, 1, &str) == FAILURE) { - WRONG_PARAM_COUNT; - } + contextnode = NULL; + contextnodep = NULL; + switch (ZEND_NUM_ARGS()) { + case 1: + if (getParameters(ht, 1, &str) == FAILURE) { + WRONG_PARAM_COUNT; + } + break; + case 2: + if (getParameters(ht, 2, &str, &contextnode) == FAILURE) { + WRONG_PARAM_COUNT; + } + break; + default: + WRONG_PARAM_COUNT; + } id = getThis(); ctxp = php_xpath_get_context(id, le_xpathctxp, 0); convert_to_string(str); + if (contextnode) { + contextnodep = php_dom_get_object(contextnode, le_domxmlnodep, 0); + } + ctxp->node = contextnodep; #if defined(LIBXML_XPTR_ENABLED) if(mode == PHP_XPTR) { xpathobjp = xmlXPtrEval(BAD_CAST str->value.str.val, ctxp); @@ -2481,7 +2499,7 @@ #if defined(LIBXML_XPTR_ENABLED) } #endif - + ctxp->node = NULL; if (!xpathobjp) { RETURN_FALSE; }
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]