Re: [xml] Re: Apparent XPath bug in libxml 2.2.7

Date view Thread view Subject view Author view

From: TOM (ptittom@free.fr)
Date: Mon Nov 13 2000 - 08:37:13 EST


On 13/11/2000 03:17:02 David Moore wrote:
> The other day I sent a message regarding a bug in libxml's 2.2.7
> xpath support in regards to evaluating relative paths.
>
> I think I've found the source of the bug. In 2.2.6, the following
> code appeared in xmlXPathEval() just before xmlXPathEvalExpr()
> gets called:
> if (ctx->node != NULL) {
> init = xmlXPathNewNodeSet(ctx->node);
> valuePush(ctxt, init);
> }
>
> In the case of relative paths, the user specifies a value for
> ctx->node and thus it is not null. Without doing the above (as it
> is in 2.2.7 and the current CVS), the CHECK_TYPE(XPATH_NODESET)
> assertion in xmlXPathNodeCollectAndTest() will fail later on.

Wouldn't it be better to add a function for setting a node as the
context node, as it is done for the root node in xmlXPathRoot ?

Something like this :
/**
 * xmlXPathSetContextNode:
 * @ctxt: the XPath Parser context
 * @node: the new context node
 *
 * Initialize the context to @node
 */
void
xmlXPathSetContextNode(xmlXPathParserContextPtr ctxt,
                       xmlNodePtr node) {
    ctxt->context->node = node;
    valuePush(ctxt, xmlXPathNewNodeSet(node));
}

Tom.

----
Message from the list xml@rpmfind.net
Archived at : http://xmlsoft.org/messages/
to unsubscribe: echo "unsubscribe xml" | mail  majordomo@rpmfind.net


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Nov 13 2000 - 09:43:42 EST