Fix bug in remapping of namespace prefixes (was not actually remapping child elements of replaced elements
This commit is contained in:
parent
d8b2497d91
commit
0bf1e8942c
4 changed files with 24 additions and 2 deletions
|
|
@ -9,6 +9,17 @@
|
|||
|
||||
<p>Copyright 2009, Jeff Schiller</p>
|
||||
|
||||
<section id="0.19">
|
||||
<header>
|
||||
<h2><a href="#0.19">Version 0.19</a></h2>
|
||||
</header>
|
||||
<p>Aug 9th, 2009</p>
|
||||
<ul>
|
||||
<li>Fix XML serialization bug: xmlns:XXX prefixes not preserved when not in default namespace</li>
|
||||
<li>Fix XML serialization bug: remapping to default namespace was not actually removing the old prefix</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section id="0.18">
|
||||
<header>
|
||||
<h2><a href="#0.18">Version 0.18</a></h2>
|
||||
|
|
|
|||
7
scour.py
7
scour.py
|
|
@ -1870,7 +1870,9 @@ def remapNamespacePrefix(node, oldprefix, newprefix):
|
|||
newNode.appendChild(child.cloneNode(True))
|
||||
|
||||
# replace old node with new node
|
||||
node = parent.replaceChild( newNode, node )
|
||||
parent.replaceChild( newNode, node )
|
||||
# set the node to the new node in the remapped namespace prefix
|
||||
node = newNode
|
||||
|
||||
# now do all child nodes
|
||||
for child in node.childNodes :
|
||||
|
|
@ -2009,10 +2011,11 @@ def scourString(in_string, options=None):
|
|||
numAttrsRemoved += 1
|
||||
|
||||
# ensure namespace for SVG is declared
|
||||
# TODO: what if the default namespace is something else (i.e. some valid namespace)?
|
||||
if doc.documentElement.getAttribute('xmlns') != 'http://www.w3.org/2000/svg':
|
||||
doc.documentElement.setAttribute('xmlns', 'http://www.w3.org/2000/svg')
|
||||
# TODO: throw error or warning?
|
||||
|
||||
|
||||
# check for redundant SVG namespace declaration
|
||||
attrList = doc.documentElement.attributes
|
||||
xmlnsDeclsToRemove = []
|
||||
|
|
|
|||
|
|
@ -868,6 +868,13 @@ class NamespaceDeclPrefixesInXMLWhenNotInDefaultNamespace(unittest.TestCase):
|
|||
xmlstring = scour.scourString(open('unittests/xml-ns-decl.svg').read())
|
||||
self.assert_( xmlstring.find('xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"') != -1,
|
||||
'Improperly serialized namespace prefix declarations when not in default namespace')
|
||||
|
||||
class MoveSVGElementsToDefaultNamespace(unittest.TestCase):
|
||||
def runTest(self):
|
||||
xmlstring = scour.scourString(open('unittests/xml-ns-decl.svg').read())
|
||||
self.assert_( xmlstring.find('<rect ') != -1,
|
||||
'Did not bring SVG elements into the default namespace')
|
||||
|
||||
# TODO; write a test for embedding rasters
|
||||
# TODO: write a test for --disable-embed-rasters
|
||||
# TODO: write tests for --keep-editor-data
|
||||
|
|
|
|||
|
|
@ -26,4 +26,5 @@
|
|||
<cc:permits id="permits6253" rdf:resource="http://web.resource.org/cc/DerivativeWorks"/>
|
||||
</cc:License>
|
||||
</rdf:RDF>
|
||||
<svg:rect width="200" height="100" />
|
||||
</svg:svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
Loading…
Add table
Add a link
Reference in a new issue