From 871b60bdf0c3dc5425d5c35265804ad065f89a3a Mon Sep 17 00:00:00 2001 From: Felix Rabe Date: Tue, 3 Nov 2009 14:44:01 +0100 Subject: [PATCH] Recursion work --- xmlmerge.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/xmlmerge.py b/xmlmerge.py index 4bf0102..df2e55c 100644 --- a/xmlmerge.py +++ b/xmlmerge.py @@ -323,11 +323,15 @@ class XMLPreprocess(object): # If not, recurse: else: - for xml_sub_element in xml_element.xpath("*"): - self(xml_sub_element, None, trace_includes, xml_filename) + self._recurse_into(xml_element) return None + def _recurse_into(self, xml_element, namespace=None): + for xml_sub_element in xml_element.xpath("*"): + self(xml_sub_element, namespace, + self.trace_includes, self.xml_filename) + _eval_substitution_regex = re.compile(r"\{(.*?)\}") def _eval_substitution(self, attr_value, namespace): @@ -366,8 +370,11 @@ class XMLPreprocess(object): def _xm_block(self, xml_element): """ Create a scope to contain visibility of newly assigned Python - variables. + variables. This works the same way that Python itself scopes + variables, i.e. by creating a shallow copy of the Python namespace. + E.g. assignments to list items will be visible to outside scopes! """ + self._recurse_into(xml_element, self.namespace.copy()) def _xm_comment(self, xml_element): """ -- 2.11.4.GIT