Back to index

plone3  3.1.7
Public Member Functions
GenericSetup.utils._Element Class Reference
Inheritance diagram for GenericSetup.utils._Element:
Inheritance graph
[legend]
Collaboration diagram for GenericSetup.utils._Element:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def writexml

Detailed Description

minidom element with 'pretty' XML output.

Definition at line 367 of file utils.py.


Member Function Documentation

def GenericSetup.utils._Element.writexml (   self,
  writer,
  indent = "",
  addindent = "",
  newl = "" 
)

Definition at line 372 of file utils.py.

00372 
00373     def writexml(self, writer, indent="", addindent="", newl=""):
00374         # indent = current indentation
00375         # addindent = indentation to add to higher levels
00376         # newl = newline string
00377         wrapper = _LineWrapper(writer, indent, addindent, newl, 78)
00378         wrapper.write('<%s' % self.tagName)
00379 
00380         # move 'name', 'meta_type' and 'title' to the top, sort the rest 
00381         attrs = self._get_attributes()
00382         a_names = attrs.keys()
00383         a_names.sort()
00384         if 'title' in a_names:
00385             a_names.remove('title')
00386             a_names.insert(0, 'title')
00387         if 'meta_type' in a_names:
00388             a_names.remove('meta_type')
00389             a_names.insert(0, 'meta_type')
00390         if 'name' in a_names:
00391             a_names.remove('name')
00392             a_names.insert(0, 'name')
00393 
00394         for a_name in a_names:
00395             wrapper.write()
00396             a_value = escape(attrs[a_name].value.encode('utf-8'), quote=True)
00397             wrapper.queue(' %s="%s"' % (a_name, a_value))
00398 
00399         if self.childNodes:
00400             wrapper.queue('>')
00401             for node in self.childNodes:
00402                 if node.nodeType == Node.TEXT_NODE:
00403                     data = escape(node.data.encode('utf-8'))
00404                     textlines = data.splitlines()
00405                     if textlines:
00406                         wrapper.queue(textlines.pop(0))
00407                     if textlines:
00408                         for textline in textlines:
00409                             wrapper.write('', True)
00410                             wrapper.queue('%s%s' % (addindent, textline))
00411                 else:
00412                     wrapper.write('', True)
00413                     node.writexml(writer, indent+addindent, addindent, newl)
00414             wrapper.write('</%s>' % self.tagName, True)
00415         else:
00416             wrapper.write('/>', True)
00417 


The documentation for this class was generated from the following file: