[XML-SIG] Re: [4suite] Where is xml.xslt?

Jeremy J Kloth jeremy.kloth@fourthought.com
Wed, 24 Jan 2001 16:45:05 -0700


> Actually, it hasn't gone well ... is this the problem you were warning me
about (I am using Windows 2000 and Python 2.0 btw):
>
[...snip traceback...]
>
> I installed the binary distribution first, before I got your message below
warning me about the clashes.  So I couldn't do what you suggested.  I am
downloading the sources right now.
>
> -- Richard A. Hein
>

There is bug in the HTML DOM implementation that is causing this error.
Below is a patch for the related files.

---PATCH---
diff -u html/HTMLCollection.py devel/Ft/Dom/html/HTMLCollection.py
--- html/HTMLCollection.py Mon Jan 15 13:21:26 2001
+++ devel/Ft/Dom/html/HTMLCollection.py Wed Jan 17 15:17:48 2001
@@ -54,11 +54,16 @@
     def namedItem(self, name):
         found_node = None
         for node in self:
+            # IDs take presedence over NAMEs
             if node.getAttribute('ID') == name:
-                return node
+                found_node = node
+                break
             if not found_node and node.getAttribute('NAME') == name \
-            and node.tagName in HTML_NAME_ALLOWED:
+               and node.tagName in HTML_NAME_ALLOWED:
+                # We found a node with NAME attribute, but we have to wait
+                # until all nodes are done (one might have an ID that
matches)
                 found_node = node
+        print 'found:', found_node
         return found_node

diff -u html/HTMLDocument.py devel/Ft/Dom/html/HTMLDocument.py
--- html/HTMLDocument.py Mon Jan 15 21:00:52 2001
+++ devel/Ft/Dom/html/HTMLDocument.py Wed Jan 17 15:36:46 2001
@@ -72,7 +72,7 @@
             elements = self.getElementsByTagName('BODY')
         if elements:
             # Replace the existing one
-            oldBody.parentNode.replaceChild(newBody, elements[0])
+            elements[0].parentNode.replaceChild(newBody, elements[0])
         else:
             # Add it
             self.documentElement.appendChild(newBody)

diff -u html/HTMLElement.py devel/Ft/Dom/html/HTMLElement.py
--- html/HTMLElement.py Mon Jan 15 13:21:16 2001
+++ devel/Ft/Dom/html/HTMLElement.py Wed Jan 17 15:22:06 2001
@@ -58,19 +57,19 @@

     def getAttribute(self, name):
         attr = self.attributes.getNamedItem(string.upper(name))
-        attr and attr.value or ''
+        return attr and attr.value or ''

     def getAttributeNode(self, name):
-        return self.attribute.getNamedItem(string.upper(name))
+        return self.attributes.getNamedItem(string.upper(name))

     def getElementsByTagName(self, tagName):
         return Element.getElementsByTagName(self, string.upper(tagName))

     def hasAttribute(self, name):
-        return self.attribute.getNamedItem(string.upper(name)) is not None
+        return self.attributes.getNamedItem(string.upper(name)) is not None

     def removeAttribute(self, name):
-        attr = set.attributes.getNamedItem(string.upper(name))
+        attr = self.attributes.getNamedItem(string.upper(name))
         attr and self.removeAttributeNode(attr)

     def setAttribute(self, name, value):
@@ -80,6 +79,18 @@
         return value

     ### Helper Functions For Cloning ###
+
+    def _4dom_clone(self, owner):
+        e = self.__class__(owner,
+                           self.tagName)
+        for attr in self.attributes:
+            clone = attr._4dom_clone(owner)
+            if clone.localName is None:
+                e.attributes.setNamedItem(clone)
+            else:
+                self.attributes.setNamedItemNS(clone)
+            clone._4dom_setOwnerElement(self)
+        return e

     def __getinitargs__(self):
         return (self.ownerDocument,

--
Jeremy Kloth                        Consultant
jeremy.kloth@fourthought.com        (303)583-9900 x 105
Fourthought, Inc.                   http://www.fourthought.com
Software-engineering, knowledge-management, XML, CORBA, Linux, Python