From 27ce474f1f589c31432119bdca226b1fb039d0ac Mon Sep 17 00:00:00 2001 From: Felix Rabe Date: Tue, 3 Nov 2009 16:46:10 +0100 Subject: [PATCH] Implement --- xmlmerge.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/xmlmerge.py b/xmlmerge.py index f42bf95..dc428e1 100644 --- a/xmlmerge.py +++ b/xmlmerge.py @@ -437,11 +437,22 @@ class XMLPreprocess(object): exec code in self.namespace del self.namespace["self"], self.namespace["xml_element"] - def _xm_removeattribute(self, xml_element): + def _xm_removeattributes(self, xml_element): """ - Remove the attribute (@name) from the element selected by XPath - (@select). + Remove the attributes (@name) from the (zero or more) elements + selected by XPath (@select). + + It is not considered an error if an attribute cannot be found on a + selected element. """ + attr_name = xml_element.get("name") + select_xpath = xml_element.get("select") + for xml_element_selected in xml_element.xpath(select_xpath): + # Can't find another way to remove an attribute than by using + # 'attrib': + attrib = xml_element_selected.attrib + if attr_name in attrib: + del xml_element_selected.attrib[attr_name] def _xm_removeelements(self, xml_element): """ -- 2.11.4.GIT