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 562557 - XPath fails to find all attributes within a given namespace
XPath fails to find all attributes within a given namespace
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
2.6.31
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2008-11-28 12:22 UTC by Emmanuel Rodriguez
Modified: 2013-08-10 16:29 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Emmanuel Rodriguez 2008-11-28 12:22:20 UTC
Please describe the problem:
I've encountered a strange XPath behavior when looking for attributes
declared within a specific namespace with libxml2. When i execute an expression if the form //@ns:* I get all the attributes in the document, no matter their namespace.

Here's a sample input file:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<rdf:RDF
 xmlns="http://www.w3.org/2000/svg"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:cc="http://web.resource.org/cc/"
 xmlns:dc="http://purl.org/dc/elements/1.1/"
 id="RDF83"
>
 <cc:Work rdf:about="" id="Work84">
  <dc:format id="format85">image/svg+xml</dc:format>
  <dc:type id="type87" rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
 </cc:Work>
</rdf:RDF>


When I try to count the attributes declared in the namespace rdf
"http://www.w3.org/1999/02/22-rdf-syntax-ns#" with the following XPath
expressions I get:

xpath count (//@rdf:*): 6 attributes
xpath count (//@*): 6 attributes
xpath count (//@*[namespace-uri() = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#']): 2 attributes

Am I wrong of thinking that //@rdf:* will find all attributes declared
in the namespace rdf or is this a bug?

Steps to reproduce:
xmllint --shel sample.xml
/ > setrootns

/ > xpath count (//@rdf:*)
Object is a number : 6

/ > xpath count (//@*)
Object is a number : 6

/ > xpath count (//@*[namespace-uri() = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'])
Object is a number : 2


Actual results:
Wrong attribute count.

Expected results:


Does this happen every time?


Other information:
Comment 1 Nick Wellnhofer 2013-08-10 16:29:46 UTC
Should be fixed with commit e8de99f9.