diff --git a/scour/scour.py b/scour/scour.py index 5ba03fd..4226ce9 100644 --- a/scour/scour.py +++ b/scour/scour.py @@ -3401,7 +3401,7 @@ def remapNamespacePrefix(node, oldprefix, newprefix): attrList = node.attributes for i in range(attrList.length): attr = attrList.item(i) - newNode.setAttributeNS(attr.namespaceURI, attr.localName, attr.nodeValue) + newNode.setAttributeNS(attr.namespaceURI, attr.name, attr.nodeValue) # clone and add all the child nodes for child in node.childNodes: diff --git a/test_scour.py b/test_scour.py index e55b9db..5f44e03 100755 --- a/test_scour.py +++ b/test_scour.py @@ -1502,7 +1502,16 @@ class RemoveRedundantSvgNamespacePrefix(unittest.TestCase): doc = scourXmlFile('unittests/redundant-svg-namespace.svg').documentElement r = doc.getElementsByTagNameNS(SVGNS, 'rect')[1] self.assertEqual(r.tagName, 'rect', - 'Redundant svg: prefix not removed') + 'Redundant svg: prefix not removed from rect') + t = doc.getElementsByTagNameNS(SVGNS, 'text')[0] + self.assertEqual(t.tagName, 'text', + 'Redundant svg: prefix not removed from text') + + # Regression test for #239 + self.assertEqual(t.getAttribute('xml:space'), 'preserve', + 'Required xml: prefix removed in error') + self.assertEqual(t.getAttribute("space"), '', + 'Required xml: prefix removed in error') class RemoveDefaultGradX1Value(unittest.TestCase): diff --git a/unittests/redundant-svg-namespace.svg b/unittests/redundant-svg-namespace.svg index 5022693..1d1dd8d 100644 --- a/unittests/redundant-svg-namespace.svg +++ b/unittests/redundant-svg-namespace.svg @@ -5,4 +5,5 @@ Test + Hallo World