1.1 --- a/README.txt Sun Sep 14 22:55:59 2008 +0200
1.2 +++ b/README.txt Fri Sep 26 23:06:24 2008 +0200
1.3 @@ -70,6 +70,8 @@
1.4 New in libxml2dom 0.5 (Changes since libxml2dom 0.4.7)
1.5 ------------------------------------------------------
1.6
1.7 + * Fixed text node handling to work around the libxml2 tendency to merge text
1.8 + nodes in its own functions.
1.9 * Changed some XML-RPC node properties in order to retain underlying DOM
1.10 properties such as data.
1.11 * Added convenience methods to the XML-RPC implementation, with combined
2.1 --- a/libxml2dom/__init__.py Sun Sep 14 22:55:59 2008 +0200
2.2 +++ b/libxml2dom/__init__.py Fri Sep 26 23:06:24 2008 +0200
2.3 @@ -19,7 +19,7 @@
2.4 with this program. If not, see <http://www.gnu.org/licenses/>.
2.5 """
2.6
2.7 -__version__ = "0.4.8"
2.8 +__version__ = "0.5"
2.9
2.10 from libxml2dom.macrolib import *
2.11 from libxml2dom.macrolib import \
2.12 @@ -396,34 +396,46 @@
2.13 raise xml.dom.WrongDocumentErr()
2.14 if oldNode.parentNode != self:
2.15 raise xml.dom.NotFoundErr()
2.16 - if hasattr(tmp, "as_native_node"):
2.17 - return self.impl.get_node(Node_insertBefore(self._node, tmp.as_native_node(), oldNode.as_native_node()), self)
2.18 - else:
2.19 - return self.impl.get_node(Node_insertBefore(self._node, tmp, oldNode.as_native_node()), self)
2.20 +
2.21 + # Nodes must be from this implementation before insertion.
2.22 +
2.23 + if not hasattr(tmp, "as_native_node"):
2.24 + raise xml.dom.WrongDocumentErr()
2.25 +
2.26 + return self.impl.get_node(Node_insertBefore(self._node, tmp.as_native_node(), oldNode.as_native_node()), self)
2.27
2.28 def replaceChild(self, tmp, oldNode):
2.29 if tmp.ownerDocument != self.ownerDocument:
2.30 raise xml.dom.WrongDocumentErr()
2.31 if oldNode.parentNode != self:
2.32 raise xml.dom.NotFoundErr()
2.33 - if hasattr(tmp, "as_native_node"):
2.34 - return self.impl.get_node(Node_replaceChild(self._node, tmp.as_native_node(), oldNode.as_native_node()), self)
2.35 - else:
2.36 - return self.impl.get_node(Node_replaceChild(self._node, tmp, oldNode.as_native_node()), self)
2.37 +
2.38 + # Nodes must be from this implementation before insertion.
2.39 +
2.40 + if not hasattr(tmp, "as_native_node"):
2.41 + raise xml.dom.WrongDocumentErr()
2.42 +
2.43 + return self.impl.get_node(Node_replaceChild(self._node, tmp.as_native_node(), oldNode.as_native_node()), self)
2.44
2.45 def appendChild(self, tmp):
2.46 if tmp.ownerDocument != self.ownerDocument:
2.47 raise xml.dom.WrongDocumentErr()
2.48 - if hasattr(tmp, "as_native_node"):
2.49 - return self.impl.get_node(Node_appendChild(self._node, tmp.as_native_node()), self)
2.50 - else:
2.51 - return self.impl.get_node(Node_appendChild(self._node, tmp), self)
2.52 +
2.53 + # Nodes must be from this implementation before insertion.
2.54 +
2.55 + if not hasattr(tmp, "as_native_node"):
2.56 + raise xml.dom.WrongDocumentErr()
2.57 +
2.58 + return self.impl.get_node(Node_appendChild(self._node, tmp.as_native_node()), self)
2.59
2.60 def removeChild(self, tmp):
2.61 - if hasattr(tmp, "as_native_node"):
2.62 - Node_removeChild(self._node, tmp.as_native_node())
2.63 - else:
2.64 - Node_removeChild(self._node, tmp)
2.65 +
2.66 + # Nodes must be from this implementation in order to be removed.
2.67 +
2.68 + if not hasattr(tmp, "as_native_node"):
2.69 + raise xml.dom.WrongDocumentErr()
2.70 +
2.71 + Node_removeChild(self._node, tmp.as_native_node())
2.72 return tmp
2.73
2.74 def getElementById(self, identifier):
3.1 --- a/libxml2dom/macrolib/__init__.py Sun Sep 14 22:55:59 2008 +0200
3.2 +++ b/libxml2dom/macrolib/__init__.py Fri Sep 26 23:06:24 2008 +0200
3.3 @@ -19,7 +19,7 @@
3.4 with this program. If not, see <http://www.gnu.org/licenses/>.
3.5 """
3.6
3.7 -__version__ = "0.4.8"
3.8 +__version__ = "0.5"
3.9
3.10 # Expose all functions here.
3.11
4.1 --- a/libxml2dom/macrolib/macrolib.py Sun Sep 14 22:55:59 2008 +0200
4.2 +++ b/libxml2dom/macrolib/macrolib.py Fri Sep 26 23:06:24 2008 +0200
4.3 @@ -429,13 +429,31 @@
4.4 return libxml2mod.xmlNewCDataBlock(Node_ownerDocument(node), value, len(value))
4.5
4.6 def Node_insertBefore(node, tmp, oldNode):
4.7 - return libxml2mod.xmlAddPrevSibling(oldNode, tmp)
4.8 +
4.9 + # Work around libxml2 tendency to merge text nodes and free nodes silently.
4.10 +
4.11 + if libxml2mod.type(tmp) == "text":
4.12 + placeholder = libxml2mod.xmlNewNode("tmp")
4.13 + placeholder = libxml2mod.xmlAddPrevSibling(oldNode, placeholder)
4.14 + libxml2mod.xmlReplaceNode(placeholder, tmp)
4.15 + return tmp
4.16 + else:
4.17 + return libxml2mod.xmlAddPrevSibling(oldNode, tmp)
4.18
4.19 def Node_replaceChild(node, tmp, oldNode):
4.20 return libxml2mod.xmlReplaceNode(oldNode, tmp)
4.21
4.22 def Node_appendChild(node, tmp):
4.23 - return libxml2mod.xmlAddChild(node, tmp)
4.24 +
4.25 + # Work around libxml2 tendency to merge text nodes and free nodes silently.
4.26 +
4.27 + if libxml2mod.type(tmp) == "text":
4.28 + placeholder = libxml2mod.xmlNewNode("tmp")
4.29 + placeholder = libxml2mod.xmlAddChild(node, placeholder)
4.30 + libxml2mod.xmlReplaceNode(placeholder, tmp)
4.31 + return tmp
4.32 + else:
4.33 + return libxml2mod.xmlAddChild(node, tmp)
4.34
4.35 def Node_removeChild(node, child):
4.36 libxml2mod.xmlUnlinkNode(child)
5.1 --- a/packages/debian-etch/python-libxml2dom/debian/changelog Sun Sep 14 22:55:59 2008 +0200
5.2 +++ b/packages/debian-etch/python-libxml2dom/debian/changelog Fri Sep 26 23:06:24 2008 +0200
5.3 @@ -1,5 +1,7 @@
5.4 libxml2dom (0.5-0ubuntu1) stable; urgency=low
5.5
5.6 + * Fixed text node handling to work around the libxml2
5.7 + tendency to merge text nodes in its own functions.
5.8 * Changed some XML-RPC node properties in order to retain
5.9 underlying DOM properties such as data.
5.10 * Added convenience methods to the XML-RPC implementation,
6.1 --- a/packages/debian-sarge/python2.3-libxml2dom/debian/changelog Sun Sep 14 22:55:59 2008 +0200
6.2 +++ b/packages/debian-sarge/python2.3-libxml2dom/debian/changelog Fri Sep 26 23:06:24 2008 +0200
6.3 @@ -1,5 +1,7 @@
6.4 libxml2dom (0.5-0ubuntu1) stable; urgency=low
6.5
6.6 + * Fixed text node handling to work around the libxml2
6.7 + tendency to merge text nodes in its own functions.
6.8 * Changed some XML-RPC node properties in order to retain
6.9 underlying DOM properties such as data.
6.10 * Added convenience methods to the XML-RPC implementation,
7.1 --- a/packages/ubuntu-feisty/python-libxml2dom/debian/changelog Sun Sep 14 22:55:59 2008 +0200
7.2 +++ b/packages/ubuntu-feisty/python-libxml2dom/debian/changelog Fri Sep 26 23:06:24 2008 +0200
7.3 @@ -1,5 +1,7 @@
7.4 libxml2dom (0.5-0ubuntu1) feisty; urgency=low
7.5
7.6 + * Fixed text node handling to work around the libxml2
7.7 + tendency to merge text nodes in its own functions.
7.8 * Changed some XML-RPC node properties in order to retain
7.9 underlying DOM properties such as data.
7.10 * Added convenience methods to the XML-RPC implementation,
8.1 --- a/packages/ubuntu-hoary/python2.4-libxml2dom/debian/changelog Sun Sep 14 22:55:59 2008 +0200
8.2 +++ b/packages/ubuntu-hoary/python2.4-libxml2dom/debian/changelog Fri Sep 26 23:06:24 2008 +0200
8.3 @@ -1,5 +1,7 @@
8.4 libxml2dom (0.5-0ubuntu1) hoary; urgency=low
8.5
8.6 + * Fixed text node handling to work around the libxml2
8.7 + tendency to merge text nodes in its own functions.
8.8 * Changed some XML-RPC node properties in order to retain
8.9 underlying DOM properties such as data.
8.10 * Added convenience methods to the XML-RPC implementation,
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2 +++ b/tests/test_text_nodes.py Fri Sep 26 23:06:24 2008 +0200
9.3 @@ -0,0 +1,30 @@
9.4 +#!/usr/bin/env python
9.5 +
9.6 +"Test text node insertion."
9.7 +
9.8 +import libxml2dom
9.9 +
9.10 +d = libxml2dom.createDocument(None, "test", None)
9.11 +
9.12 +t1 = d.createTextNode("Hello ")
9.13 +t2 = d.createTextNode("world")
9.14 +t3 = d.createTextNode("!")
9.15 +
9.16 +t1x = d.documentElement.appendChild(t1)
9.17 +t3x = d.documentElement.appendChild(t3)
9.18 +
9.19 +print d.toString()
9.20 +assert t2.parentNode is None
9.21 +assert t1.parentNode is not None
9.22 +assert t3.parentNode is not None
9.23 +
9.24 +t2x = d.documentElement.insertBefore(t2, t3)
9.25 +
9.26 +print d.toString()
9.27 +
9.28 +l = [n.data for n in t1.parentNode.childNodes]
9.29 +
9.30 +print l
9.31 +assert len(l) == 3
9.32 +
9.33 +# vim: tabstop=4 expandtab shiftwidth=4