Re: [xml] XPath Node Selection Using ...[@attr="value"]

Date view Thread view Subject view Author view

From: Tim Ruddick (truddick@eng.us.uu.net)
Date: Wed May 10 2000 - 19:30:25 EDT


On Wed, 26 Apr 2000, Tim Ruddick wrote:

> On Wed, 26 Apr 2000, Daniel Veillard wrote:
> > Sorry I didn't focuse on the XPath state lately but rather on interfaces
> > XML conformances for libxml2.
>
> Understood. That seems to me like the right approach, too.
>
> > I would appreciate if volunteers could look at those issues (and
> > possibly send patches ;-). At least a good pinpointing of the problem
> > would help me fix them quickly.
>
> I'll see what I can do. Acquainting myself with the code may take a
> little while, of course.

I've been looking through the xpath code. Interesting.

One thing that strikes me is that the comments appear to reflect a version
of the grammar that is specified in

   http://www.w3.org/1999/07/WD-xpath-19990709

(or perhaps earlier), but the latest version of the grammar is different

   http://www.w3.org/TR/xpath

I believe that some of the [@attr="value"] confusion arises in grammar
rule [4], which the xpath.c code lists as

   [4] Step ::= Basis Predicate*
               | AbbreviatedStep

But which the most recent grammar lists as

   [4] Step ::= AxisSpecifier NodeTest Predicate*
               | AbbreviatedStep

This leads to two or more possible theories, including: (1) the code
implements the grammar listed in the comments, but that grammar is now out
of date; or (2) the code implements the new grammar, but the comments
haven't been changed to reflect that.

I'm not at all certain whether this is causing the problem, but it bears
looking into.

I also note that when the time comes to compare the attributes, the parser
is pushing "attribute" nodes onto its context stack, and not "child" nodes
as I would expect. To manufacture an example, given the XML snippet

   <base>
       <node num="1">one</node>
       <node num="2">two</node>
       <node num="3">three</node>
   </base>

and the xpath expression

   /base/node[@num="1"]

the parser appears to push three attribute nodes onto the context stack,
and never gets around to finding the match against "1" and pushing the
single matching child node. I fear I may not be explaining this very
clearly. I'm still investigating.

Tim.

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


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Wed Aug 02 2000 - 12:30:11 EDT