+import sys
import xml.dom.minidom
class node(object):
return self.__todom__(doc).toxml()
class context(object):
+ charset = (sys.getfilesystemencoding() or "ascii")
+
def __init__(self):
self.nodeconv = {}
- self.nodeconv[bytes] = lambda ob: text(ob, "utf-8")
+ self.nodeconv[bytes] = lambda ob: text(ob, self.charset)
self.nodeconv[str] = text
self.nodeconv[int] = text
self.nodeconv[float] = text
node.children.append(self.nodefrom(child))
def addattr(self, node, k, v):
- node.attrs[str(k)] = str(v)
+ if v is not None:
+ node.attrs[str(k)] = str(v)
class constructor(object):
- def __init__(self, ns, elcls = element, ctx=None):
+ def __init__(self, ns, elcls=element, ctx=None):
self._ns = ns
self._elcls = elcls
if ctx is None: ctx = context()