GNOME Bugzilla – Bug 562557
XPath fails to find all attributes within a given namespace
Last modified: 2013-08-10 16:29:46 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:
Should be fixed with commit e8de99f9.