After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 750037 - XPath searching for nodes within a namespace only finds every second node
XPath searching for nodes within a namespace only finds every second node
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
git master
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2015-05-28 14:14 UTC by CJ Dennis
Modified: 2016-05-05 14:11 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description CJ Dennis 2015-05-28 14:14:44 UTC
The running the following XPath over the example XML should find all element nodes since all of their ancestor-or-self contains a matching namespace declaration. However, it only finds every second node, i.e. <root/>, <two/> and <four/>.


XML:
<root xmlns:ns="foo"ns:id="1"> <one/> <two/> <three/>
<four/> <five/> </root>

XPath:
//node()[namespace::ns]
Comment 1 Daniel Veillard 2015-05-29 07:19:24 UTC
Weird indeed, I can reproduce it, sounds like a genuine bug :-\

thinkpad2:~/XML -> ./xmllint --shell tst750037.xml
/ > setns ns=foo          
/ > xpath //node()
Object is a Node Set :
Set contains 12 nodes:
1  ELEMENT root
    namespace ns href=foo
    ATTRIBUTE id
      TEXT
        content=1
2  TEXT
    content= 
3  ELEMENT one
4  TEXT
    content= 
5  ELEMENT two
6  TEXT
    content= 
7  ELEMENT three
8  TEXT
    content= 
9  ELEMENT four
10  TEXT
    content= 
11  ELEMENT five
12  TEXT
    content= 
/ > xpath //node()[namespace::ns]
Object is a Node Set :
Set contains 3 nodes:
1  ELEMENT root
    namespace ns href=foo
    ATTRIBUTE id
      TEXT
        content=1
2  ELEMENT two
3  ELEMENT four
/ > quit
Comment 2 Nick Wellnhofer 2016-05-05 14:11:03 UTC
Fixed with the following commit:

https://git.gnome.org/browse/libxml2/commit/?id=82b73039dc0eed620621cb699b1140c6e0c89cce