GNOME Bugzilla – Bug 309864
xpath attribute::name matches fails
Last modified: 2009-08-15 18:40:50 UTC
Version details: Fedora Core RPMS Distribution/Version: Fedora Core Given this document (test.xml): <opt name="foo"/> Trying to evaluate xpath child::opt/attribute::name with libxml-2.6.19 (FC4) fails to find the attribute: # xmlint --shell test.xml / > xpath child::opt/attribute::name Object is a Node Set : Set contains 0 nodes: With libxml-2.6.16 (FC3) the same succeeds: # xmllint --shell test.xml / > xpath child::opt/attribute::name Object is a Node Set : Set contains 1 nodes: 1 ATTRIBUTE name TEXT content=foo However, xpath child::opt/attribute::* with both versions succeeds.
There is a problem within the xpath evaluation with 'attribute::name'. The fix for this is currently under discussion and should be resolved soon; in the meantime, you should find that 'child::opt/@name' works as expected. *** This bug has been marked as a duplicate of 309580 ***
I am having doubts on this PR to be a duplicate of PR 309580, because 1. I am able to reproduce the results above without having libxslt installed. # rpm -q libxslt libxml2 package libxslt is not installed libxml2-2.6.19-1 2. Downgrading from libxml2-2.6.19 to libxml2-2.6.16 lets this issue disappear: # cat xyz.xml <opt name="foo"/> # xmllint --shell xyz.xml / > xpath child::opt/attribute::name Object is a Node Set : Set contains 0 nodes: / > xpath child::opt/attribute::* Object is a Node Set : Set contains 1 nodes: 1 ATTRIBUTE name TEXT content=foo Downgrading: # rpm -U --oldpackage libxml2-2.6.16-3.i386.rpm --nodeps # xmllint --shell xyz.xml / > xpath child::opt/attribute::name Object is a Node Set : Set contains 1 nodes: 1 ATTRIBUTE name TEXT content=foo / > xpath child::opt/attribute::* Object is a Node Set : Set contains 1 nodes: 1 ATTRIBUTE name TEXT content=foo => This is a bug in libxml2, not in libxslt
libxslt uses libxml2. Although the bug report was filed under libxslt (because that's where the problem was encountered), the actual problem is within the XPath module of libxml2. The resolution of that bug will actually involve a change to the current code of libxml2/xpath.c. Trust me, as soon as bug 309580 is fixed, this problem will also be fixed :-)
OK, this give sense - Thanks for clarifying this.
I think I fixed it in CVS, this was introduced in 2.6.19 and will be fixed in 2.6.20, thanks for the heads up ! Daniel
This should be closed by release of libxml2-2.6.21, thanks, Daniel