From: Radek Pazdera <rpazdera(a)redhat.com>
Comments in the XML recipe might interfere with the parser in some
cases and result in exceptions. The best way to deal with this is
to remove them from the recipe.
Signed-off-by: Radek Pazdera <rpazdera(a)redhat.com>
---
Common/XmlPreprocessor.py | 15 +++++++++++++++
NetTest/NetTestParse.py | 2 ++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/Common/XmlPreprocessor.py b/Common/XmlPreprocessor.py
index 21ce86e..be2cab2 100644
--- a/Common/XmlPreprocessor.py
+++ b/Common/XmlPreprocessor.py
@@ -50,6 +50,21 @@ class XmlPreprocessor:
else:
raise XmlTemplateError("Alias name '%s' is reserved" %
name)
+ def remove_comments(self, node):
+ """
+ Remove all comment nodes from the tree.
+ """
+
+ comments = []
+ for child in node.childNodes:
+ if child.nodeType == node.COMMENT_NODE:
+ comments.append(child)
+ else:
+ self.remove_comments(child)
+
+ for comment in comments:
+ node.removeChild(comment)
+
def expand(self, node):
"""
Traverse DOM tree from `node' down and expand any
diff --git a/NetTest/NetTestParse.py b/NetTest/NetTestParse.py
index 5b5101a..68c0058 100644
--- a/NetTest/NetTestParse.py
+++ b/NetTest/NetTestParse.py
@@ -81,6 +81,8 @@ class NetTestParse:
dom = parseString(self._recipe_xml_string)
xml_prep = self._xml_prep
+ xml_prep.remove_comments(dom)
+
self._load_included_parts(dom)
dom_nettestrecipe = dom.getElementsByTagName("nettestrecipe")[0]
--
1.7.7.6