Bug with predicates using "and"

Murat <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
Hi all,

I just looked into how predicates are evaluated, using the
debian/ubuntu command-line version of this module. I believe the
modules way to determine the context set during predicate evaluation
is flawed. Could you confirm this?

To reproduce, consider the following XML document and XPath queries.

<root>
  <kid id="alpha"/>
  <kid id="beta"  attr="1"/>
  <kid id="gamma" attr="2"/>
</root>


/root/kid[3][@attr]
Delivers kid "gamma". Correct.

/root/kid[@attr][2]
Delivers kid "gamma". Correct, too.

/root/kid[position()=2 and @attr]
Delivers kid "beta". Correct.

/root/kid[@attr and position()=2]
Delivers nothing. Incorrect.
The position should be the position in the context set prior to the
evaluation of this predicate. In this case, this should be all kid
elements. in any case, the query should yield the same as the above
one, since I only switched the operands to a logical "and".

/root/kid[@attr and position()=1]
Delivers kid elements "beta" and "gamma". Incorrect.
Should only yield kid "beta".

Can you confirm this is a bug, or tell me where I didnt understand the
specification? Evaluating these queries with the XPather plugin yields
results as expected (by me).

If its a bug, then my guess is, that you do some preprocess step and
split Predicates with "and" into two, which, unfortunately, does not
consider the context set as it should.

Best Regards,
Murat
_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.