summaryrefslogtreecommitdiffstats
path: root/rteval/xmlout.py
diff options
context:
space:
mode:
authorClark Williams <williams@redhat.com>2009-03-12 13:35:47 -0500
committerClark Williams <williams@redhat.com>2009-03-12 13:35:47 -0500
commite01928472913ec145739b37e013490fc4142af74 (patch)
tree0b5232f36cac9e8c773373f0083a15d2394f1eba /rteval/xmlout.py
parent293f4c8809ef1b6de8e53ae556a06b0c5261a573 (diff)
downloadrteval-e01928472913ec145739b37e013490fc4142af74.tar.gz
rteval-e01928472913ec145739b37e013490fc4142af74.tar.xz
rteval-e01928472913ec145739b37e013490fc4142af74.zip
made tags safe
Diffstat (limited to 'rteval/xmlout.py')
-rw-r--r--rteval/xmlout.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/rteval/xmlout.py b/rteval/xmlout.py
index 2b42f4c..877974e 100644
--- a/rteval/xmlout.py
+++ b/rteval/xmlout.py
@@ -11,7 +11,7 @@ class XMLOut(object):
'''Class to create XML output'''
def __init__(self, roottag, version, attr = None, encoding='UTF-8'):
self.encoding = encoding
- self.roottag = roottag
+ self.roottag = self.__fixtag(roottag)
self.rootattr = attr
self.version = version
self.status = 0 # 0 - no report created/loaded, 1 - new report, 2 - loaded report, 3 - XML closed
@@ -42,6 +42,10 @@ class XMLOut(object):
node.newProp(k, self.__encode(v))
+ def __fixtag(self, tagname):
+ tmp = tagname.replace(' ', '_')
+ return tmp.replace('\t', '_')
+
def close(self):
if self.status == 0:
raise RuntimeError, "XMLOut: No XML document is created nor loaded"
@@ -136,7 +140,7 @@ class XMLOut(object):
def openblock(self, tagname, attributes=None):
if self.status != 1:
raise RuntimeError, "XMLOut: openblock() cannot be called before NewReport() is called"
- ntag = libxml2.newNode(tagname);
+ ntag = libxml2.newNode(self.__fixtag(tagname));
self.__add_attributes(ntag, attributes)
self.currtag.addChild(ntag)
self.currtag = ntag
@@ -155,7 +159,7 @@ class XMLOut(object):
def taggedvalue(self, tag, value, attributes=None):
if self.status != 1:
raise RuntimeError, "XMLOut: taggedvalue() cannot be called before NewReport() is called"
- ntag = self.currtag.newTextChild(None, tag, self.__encode(value))
+ ntag = self.currtag.newTextChild(None, self.__fixtag(tag), self.__encode(value))
self.__add_attributes(ntag, attributes)