1.1 --- a/libxml2dom/__init__.py Tue Mar 13 00:16:45 2007 +0000
1.2 +++ b/libxml2dom/__init__.py Tue Mar 13 00:16:45 2007 +0000
1.3 @@ -41,6 +41,11 @@
1.4 def createDocument(self, namespaceURI, localName, doctype):
1.5 return Document(Node_createDocument(namespaceURI, localName, doctype), self)
1.6
1.7 + # Wrapping of documents.
1.8 +
1.9 + def adoptDocument(self, node):
1.10 + return Document(node, self)
1.11 +
1.12 # Factory functions.
1.13
1.14 def get_node(self, _node, context_node):
1.15 @@ -190,6 +195,9 @@
1.16 def _namespaceURI(self):
1.17 return Node_namespaceURI(self._node)
1.18
1.19 + def _textContent(self):
1.20 + return Node_textContent(self._node)
1.21 +
1.22 def _nodeValue(self):
1.23 if self.nodeType in null_value_node_types:
1.24 return None
1.25 @@ -372,6 +380,7 @@
1.26
1.27 childNodes = property(_childNodes)
1.28 value = data = nodeValue = property(_nodeValue, _setNodeValue)
1.29 + textContent = property(_textContent)
1.30 name = nodeName = property(_nodeName)
1.31 tagName = property(_tagName)
1.32 namespaceURI = property(_namespaceURI)
1.33 @@ -519,7 +528,7 @@
1.34 """
1.35
1.36 impl = impl or default_impl
1.37 - return Document(Node_parseFile(filename, html), impl)
1.38 + return impl.adoptDocument(Node_parseFile(filename, html))
1.39
1.40 def parseString(s, html=0, impl=None):
1.41
1.42 @@ -532,7 +541,7 @@
1.43 """
1.44
1.45 impl = impl or default_impl
1.46 - return Document(Node_parseString(s, html), impl)
1.47 + return impl.adoptDocument(Node_parseString(s, html))
1.48
1.49 def parseURI(uri, html=0, impl=None):
1.50
1.51 @@ -563,7 +572,7 @@
1.52 f.close()
1.53 else:
1.54 impl = impl or default_impl
1.55 - return Document(Node_parseURI(uri, html), impl)
1.56 + return impl.adoptDocument(Node_parseURI(uri, html))
1.57
1.58 def toString(node, encoding=None, prettyprint=0):
1.59
1.60 @@ -613,7 +622,7 @@
1.61
1.62 if len(nodes) == 0:
1.63 return []
1.64 - doc = Document(libxml2mod.doc(nodes[0]), impl)
1.65 + doc = impl.adoptDocument(libxml2mod.doc(nodes[0]))
1.66 results = []
1.67 for node in nodes:
1.68 results.append(Node(node, impl, doc))