1.1 --- a/libxml2dom/__init__.py Tue Feb 27 23:17:30 2007 +0000
1.2 +++ b/libxml2dom/__init__.py Tue Feb 27 23:17:57 2007 +0000
1.3 @@ -166,9 +166,9 @@
1.4 PROCESSING_INSTRUCTION_NODE = xml.dom.Node.PROCESSING_INSTRUCTION_NODE
1.5 TEXT_NODE = xml.dom.Node.TEXT_NODE
1.6
1.7 - def __init__(self, node, impl, ownerDocument=None):
1.8 + def __init__(self, node, impl=None, ownerDocument=None):
1.9 self._node = node
1.10 - self.impl = impl
1.11 + self.impl = impl or default_impl
1.12 self.ownerDocument = ownerDocument
1.13
1.14 def as_native_node(self):
1.15 @@ -190,6 +190,8 @@
1.16 return Node_namespaceURI(self._node)
1.17
1.18 def _nodeValue(self):
1.19 + if self.nodeType in null_value_node_types:
1.20 + return None
1.21 return Node_nodeValue(self._node)
1.22
1.23 def _setNodeValue(self, value):
1.24 @@ -470,13 +472,20 @@
1.25 self.entities = {}
1.26 self.notations = {}
1.27
1.28 +# Constants.
1.29 +
1.30 +null_value_node_types = [
1.31 + Node.DOCUMENT_NODE, Node.DOCUMENT_TYPE_NODE, Node.ELEMENT_NODE,
1.32 + Node.ENTITY_NODE, Node.ENTITY_REFERENCE_NODE, Node.NOTATION_NODE
1.33 + ]
1.34 +
1.35 # Utility functions.
1.36
1.37 def createDocumentType(localName, publicId, systemId):
1.38 - return impl.createDocumentType(localName, publicId, systemId)
1.39 + return default_impl.createDocumentType(localName, publicId, systemId)
1.40
1.41 def createDocument(namespaceURI, localName, doctype):
1.42 - return impl.createDocument(namespaceURI, localName, doctype)
1.43 + return default_impl.createDocument(namespaceURI, localName, doctype)
1.44
1.45 def parse(stream_or_string, html=0, impl=None):
1.46