summaryrefslogtreecommitdiff
path: root/suds/sax/document.py
diff options
context:
space:
mode:
authorjortel <devnull@localhost>2010-08-31 15:25:01 +0000
committerjortel <devnull@localhost>2010-08-31 15:25:01 +0000
commitada7dd09c10865a67049a85ccd688167aefad3c2 (patch)
tree500baa56325a3becaea3e49b3818d85c2c86ed60 /suds/sax/document.py
parent2ee83e241c78db8b1a25d5182873470137394ad1 (diff)
downloadsuds-ada7dd09c10865a67049a85ccd688167aefad3c2.tar.gz
Add option: 'prettyxml' default=0 to control output XML as pretty printed or not.
Diffstat (limited to 'suds/sax/document.py')
-rw-r--r--suds/sax/document.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/suds/sax/document.py b/suds/sax/document.py
index c7129cb..5a004eb 100644
--- a/suds/sax/document.py
+++ b/suds/sax/document.py
@@ -27,6 +27,8 @@ log = getLogger(__name__)
class Document(Element):
""" simple document """
+
+ DECL = '<?xml version="1.0" encoding="UTF-8"?>'
def __init__(self, root=None):
Element.__init__(self, 'document')
@@ -34,18 +36,26 @@ class Document(Element):
self.append(root)
def root(self):
- if len(self.children) > 0:
+ if len(self.children):
return self.children[0]
else:
return None
+ def str(self):
+ s = []
+ s.append(self.DECL)
+ s.append('\n')
+ s.append(self.root().str())
+ return ''.join(s)
+
+ def plain(self):
+ s = []
+ s.append(self.DECL)
+ s.append(self.root().plain())
+ return ''.join(s)
+
def __str__(self):
return unicode(self).encode('utf-8')
def __unicode__(self):
- result = '<?xml version="1.0" encoding="UTF-8"?>'
- root = self.root()
- if root is not None:
- result += '\n'
- result += root.str()
- return unicode(result)
+ return self.str() \ No newline at end of file