Re: [xml] Question regarding XPath



On Thu, 15 Mar 2007 13:14:18 -0500, Daniel Veillard <veillard redhat com> wrote:

Many bugs have been fixed since 2.6.9, so it's likely a bug on your side,
but I have no idea what this could be, try to reproduce it with
xmllint --shell (see setns and xpath commands) and provide an instance of
XML showing the problem.

Hi, Daniel.

Thanks for your email. I'm sorry for the delayed response; I was working with a few different issues to see if I could figure out what was happening. xmllint does the Right Thing (i.e., it finds the fifty nodes we're trying to select), which is good. I've been looking at it and the debugAPI code for awhile now.

By comparison, the xpath1 and xpath2 examples both return zero nodes when executed on the schema with the same query. So it seems to me like xmllint is doing something different than the two examples provided.

As far as I can tell, xmllint does the following:

. In response to "setns", it makes a call to xmlShellRegisterNamespace. This parses the provided argument into a prefix and href and registers the result with a call to xmlXPathRegisterNs.

. In response to "xpath", it makes a call to xmlXPathEval, passing the query and the document context (I think--it could also be the XPath context, but it's hard to tell from the code).

This isn't terribly complicated, and it looks pretty similar to what's happening in xpath1.c:

. The example basically lifted the code from xmllist to register the namespaces.

. It then evaluates the expression using the xmlXPathEvalExpression method, passing the query and the XPath context.

So it differs in how it evaluates the expression. Namely, it uses a different method and possibly a different context.


Our code is similar. We really differ in that we don't need to parse the namespaces in the same way. I've double-checked to make sure that we are actually registering valid namespaces, just to be safe, and we are. So I think the issue lies in how we're evaluating the XPath query. Can you shed some light on how xmlXPathEval differs from xmlXPathEvalExpression, and whether the issue is related to the context passed?

Thanks again for all your help.


Best,

Ethan

--
Objective Systems, Inc.
REAL WORLD ASN.1 AND XML SOLUTIONS
Tel: +1 (484) 875-9841
Fax: +1 (484) 875-9830
Toll-free: (877) 307-6855 (USA only)
http://www.obj-sys.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]