-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
[Description]
Since XPathContext tries to retrieve the default namespace URI from the
document elements' xmlns attribute, it doesn't work in the following situation
where a) xmlns attribute is modified afterward b) the default namespace URI for
the document without namespace specifications is implied by the DOM parser.
I was stuck on this in the case (b) because I have a DOM implementation other
than minidom (actually backed by the WebKit DOM through PyObjC).
Patch attached.
[Code for reproduction]
from xml.dom.minidom import parseString
from xpath import XPathContext
doc = parseString('''
<foo xmlns="http://foo.example.com/">
<item>foo</item>
<item xmlns="http://bar.example.com/">bar</item>
</foo>
''')
doc.documentElement.setAttribute('xmlns', 'http://bar.example.com/')
assert doc.documentElement.namespaceURI == 'http://foo.example.com/'
assert doc.documentElement.getAttribute('xmlns') == 'http://bar.example.com/'
nodeset = XPathContext(doc).find('//item', doc)
assert len(nodeset) == 1
assert nodeset[0].namespaceURI == 'http://foo.example.com/' # boom!
[What version of the product are you using? On what operating system?]
SVN head
Original issue reported on code.google.com by m...@mozo.jp on 6 Jan 2013 at 12:09
Attachments:
Reactions are currently unavailable