[Zope3-checkins] CVS: zopeproducts/xml/dom - printer.py:1.2

Philipp von Weitershausen philikon@philikon.de
Sun, 22 Jun 2003 20:15:14 -0400


Update of /cvs-repository/zopeproducts/xml/dom
In directory cvs.zope.org:/tmp/cvs-serv19218

Modified Files:
	printer.py 
Log Message:
Took out upper case printing for HTML. The printer will (and should) print
the tag names as the DOM stores them.


=== zopeproducts/xml/dom/printer.py 1.1 => 1.2 ===
--- zopeproducts/xml/dom/printer.py:1.1	Fri Jun 20 19:40:39 2003
+++ zopeproducts/xml/dom/printer.py	Sun Jun 22 20:15:14 2003
@@ -29,25 +29,15 @@
 
 class Printer:
     """
-    A XML printer which can do optional pretty printing
+    A DOM to XML printer which can do optional pretty printing
     """
 
     implements(IPrinter)
 
-    def __init__(self, encoding=None, html=False, contentType=None,
-                 entityReferenceExpansion=True, prettyPrint=False,
-                 indentLevel=2):
-        self.namePrint = lambda s: s # identity
-
-        if contentType and html:
-            if contentType == 'html':
-                self.namePrint = string.upper
-            elif contentType == 'xml':
-                self.namePrint = string.lower
-
+    def __init__(self, encoding=None, html=False, entityReferenceExpansion=True,
+                 prettyPrint=False, indentLevel=2):
         self.encoding = encoding
         self.html = html
-        self.contentType = contentType
         self.entityReferenceExpansion = entityReferenceExpansion
         self.prettyPrint = prettyPrint
         self.indent = 0
@@ -76,14 +66,14 @@
         if self.prettyPrint:
             f.write(" " * self.indent * self.indentLevel)
         f.write("<")
-        f.write(self.namePrint(node.tagName))
+        f.write(node.tagName)
         for attribute in node.attributes.values():
             self.renderAttr(f, attribute)
         if not node.hasChildNodes():
             if self.html:
                 if node.tagName.upper() not in HTML_FORBIDDEN_END:
                     f.write('></')
-                    f.write(self.namePrint(node.tagName))
+                    f.write(node.tagName)
                     f.write('>')
                 else:
                     f.write(' />')
@@ -123,7 +113,7 @@
                 self.indent -= 1
                 
                 f.write(" " * self.indent * self.indentLevel)
-            f.write("</%s>" % self.namePrint(node.tagName))
+            f.write("</%s>" % node.tagName)
             if self.prettyPrint:
                 f.write("\n")
 
@@ -132,8 +122,7 @@
             return
         text, delimiter = _translateCdataAttr(node.value,
                                               encoding=self.encoding)
-        f.write(" %s=%s%s%s" % (self.namePrint(node.name),
-                                delimiter, text, delimiter))
+        f.write(" %s=%s%s%s" % (node.name, delimiter, text, delimiter))
 
     def renderText(self, f, node):
         data = node.data