From ccf38d37c54a85b356d6c13a53aa6c79330ea4e4 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Wed, 15 Jul 2009 14:03:49 +0200 Subject: Added new method GetXMLdocument() This method returns a libxml2.xmlDoc object, for further manual processing. Fixed in addition an error, trying to access self.xmldoc before it was initialised. --- rteval/xmlout.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'rteval/xmlout.py') diff --git a/rteval/xmlout.py b/rteval/xmlout.py index 2b2768a..a17206f 100644 --- a/rteval/xmlout.py +++ b/rteval/xmlout.py @@ -18,11 +18,13 @@ class XMLOut(object): self.status = 0 # 0 - no report created/loaded, 1 - new report, 2 - loaded report, 3 - XML closed self.tag_trans = self.__setup_tag_trans() self.roottag = self.__fixtag(roottag) - + self.xmldoc = None + def __del__(self): if self.level > 0: raise RuntimeError, "XMLOut: open blocks at __del__ (last opened '%s')" % self.currtag.name - self.xmldoc.freeDoc() + if self.xmldoc is not None: + self.xmldoc.freeDoc() def __setup_tag_trans(self): t = maketrans('', '') @@ -180,6 +182,10 @@ class XMLOut(object): resdoc.freeDoc() xsltdoc.freeDoc() + def GetXMLdocument(self): + if self.status != 2 and self.status != 3: + raise RuntimeError, "XMLOut: XML document is not closed" + return self.xmldoc def openblock(self, tagname, attributes=None): if self.status != 1: -- cgit