[XML-SIG] cloneNode doesn't copy attributes?
Martin v. Loewis
martin@v.loewis.de
Sun, 20 Jan 2002 11:29:26 +0100
> It seems that cloneNode in python-xml 0.7 (latest Debian unstable
> python2.2-xml) doesn't copy attributes. Should it?
It should; it is a typo in HTMLElement that it doesn't. Please apply
the patch
Index: HTMLElement.py
===================================================================
RCS file: /cvsroot/pyxml/xml/xml/dom/html/HTMLElement.py,v
retrieving revision 1.8
diff -u -r1.8 HTMLElement.py
--- HTMLElement.py 2001/02/20 01:00:04 1.8
+++ HTMLElement.py 2002/01/20 10:22:49
@@ -88,7 +88,7 @@
if clone.localName is None:
e.attributes.setNamedItem(clone)
else:
- self.attributes.setNamedItemNS(clone)
+ e.attributes.setNamedItemNS(clone)
clone._4dom_setOwnerElement(self)
return e
> What am I doing wrong/what doco should I read?
It would be good to read the DOM specification; see
http://www.w3.org/TR/DOM-Level-2-Core/
In the definition of cloneNode, it quite explicitly states what to
copy.
> I've made several attempts to write something as simple as this, but
> it seems not a trivial to determine which examples are obsolete, and
> which are preferred now (xml.dom.html_builder.HtmlBuilder and
> HtmlWriter are too old, pyexpat is too new/not for plain HTML, SAX is
> simple, but I don't want simple, rather standard and java-like, but in
> python, right? -- dazzle).
I'm not sure what 'this' is precisely; SAX is both standard and
Java-like. It is true that some examples are outdated; contributions
are welcome.
Regards,
Martin