Created attachment 1181748 [details] old version I recently took out one of my older scripts that xpaths a few XML lines online. The command is rather simple: xmllint --xpath "//title[1]" "http://derStandard.at/?page=rss" Unfortunately I realized that the output from libxml2-2.9.1-5.fc22.i686.rpm towards libxml2-2.9.2-1.fc22.i686.rpm and upwards has changed. The xpath should return the first element of title in an array of titles. While 2.9.1-5 (and older version that also came bundled with e.g. fedora 20) works as I expect, the version that came after that returns *all* title elements. Please find attached 2 log files showing the returned content. Might this be an uncovered issue ? Btw: I am reporting this bug for fedora 22 and would like to receive a fixed package for it. If possible.
Created attachment 1181749 [details] new version All versions after that seem to be affected by this issue.
Ok saw that Fedora 22 received EOL today *darn* but the bug might be still valid one. Please test and fix. Will be updating to Fedora 24 in a couple of days anyways.
I just tested this under Fedora 24 and the problem is there too. I had to recompile an old Fedora 22 Version for Fedora 24 to get the XPath correctly. It would be nice to have that one solved. Thanks.
I was able to track the issue down to this: ----------------------------------------- commit b4bcba23f64b71105514875f165a63d4cc720609 Author: Nick Wellnhofer <wellnhofer> Date: Mon Aug 5 00:15:11 2013 +0200 Fix XPath '//' optimization with predicates My attempt to optimize XPath expressions containing '//' caused a regression reported in bug #695699. This commit disables the optimization for expressions of the form '//foo[predicate]'. ----------------------------------------- What I did: 1) I downloaded libxml2 from git (Upstream: HEAD) 2) I then retagged libxml2 to a certain commit (starting at 2.9.1) 3) I then grabbed one commit after another, recompiled, reinstalled and tested The above optimization is the issue of xpath fails. Hope I was able to help and would like to see it fixed if possible.
The behavior of libxml2 2.9.2 is correct (and should also match the behavior of 2.9.0 and previous versions). The only broken version is 2.9.1. An expression of the form //title[1] should really return the first title child of every node containing titles. If you want the first title in the whole document, try (//title)[1].
Interesting! This means - if I understand it correctly - the correct way is that //title[1] returns not just the first element but also all first elements down the tree (of all the children and siblings that may follow). Thanks for the feedback then. I wondered and thought this to be a bug because one of my scripts failed to work (written around the 2.9.1 release date back in 2013). Will adopt your suggestion with (//tile)[1] then. Thanks for the feedback.
This works... Thanks! Gonna close the report!