summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjortel <devnull@localhost>2011-07-11 21:05:27 +0000
committerjortel <devnull@localhost>2011-07-11 21:05:27 +0000
commit155ed3f8e0cb4b927274a5eb9c3f7362d9debded (patch)
treeaa2b056a33b83a5a48ac04a1a180898c18575ed5
parentc61299de5f6c840fe381832f130ae3b73d136935 (diff)
downloadsuds-155ed3f8e0cb4b927274a5eb9c3f7362d9debded.tar.gz
Handle str() and plain() when document root is (None).
-rw-r--r--suds/sax/document.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/suds/sax/document.py b/suds/sax/document.py
index 5a004eb..b5ba22f 100644
--- a/suds/sax/document.py
+++ b/suds/sax/document.py
@@ -34,24 +34,43 @@ class Document(Element):
Element.__init__(self, 'document')
if root is not None:
self.append(root)
-
+
def root(self):
+ """
+ Get the document root element (can be None)
+ @return: The document root.
+ @rtype: L{Element}
+ """
if len(self.children):
return self.children[0]
else:
return None
def str(self):
+ """
+ Get a string representation of this XML fragment.
+ @return: A I{pretty} string.
+ @rtype: basestring
+ """
s = []
s.append(self.DECL)
- s.append('\n')
- s.append(self.root().str())
+ root = self.root()
+ if root is not None:
+ s.append('\n')
+ s.append(root.str())
return ''.join(s)
def plain(self):
+ """
+ Get a string representation of this XML fragment.
+ @return: A I{plain} string.
+ @rtype: basestring
+ """
s = []
s.append(self.DECL)
- s.append(self.root().plain())
+ root = self.root()
+ if root is not None:
+ s.append(self.root().plain())
return ''.join(s)
def __str__(self):