Fix Bug 436569: Get xlink:href prefix right in case of duplicate gradient
This commit is contained in:
parent
7e483ce92f
commit
20fe836041
3 changed files with 39 additions and 5 deletions
12
scour.py
12
scour.py
|
|
@ -2071,11 +2071,15 @@ def serializeXML(element, options, ind = 0, preserveWhitespace = False):
|
||||||
|
|
||||||
outString += ' '
|
outString += ' '
|
||||||
# preserve xmlns: if it is a namespace prefix declaration
|
# preserve xmlns: if it is a namespace prefix declaration
|
||||||
if attr.namespaceURI == 'http://www.w3.org/2000/xmlns/' and attr.nodeName.find('xmlns') == -1:
|
if attr.prefix != None:
|
||||||
outString += 'xmlns:'
|
outString += attr.prefix + ':'
|
||||||
outString += attr.nodeName + '=' + quot + attrValue + quot
|
elif attr.namespaceURI != None:
|
||||||
|
if attr.namespaceURI == 'http://www.w3.org/2000/xmlns/' and attr.nodeName.find('xmlns') == -1:
|
||||||
|
outString += 'xmlns:'
|
||||||
|
elif attr.namespaceURI == 'http://www.w3.org/1999/xlink':
|
||||||
|
outString += 'xlink:'
|
||||||
|
outString += attr.localName + '=' + quot + attrValue + quot
|
||||||
|
|
||||||
# TODO: when to set preserveWhitespace to true, with a value of 'none'?
|
|
||||||
if attr.nodeName == 'xml:space':
|
if attr.nodeName == 'xml:space':
|
||||||
if attrValue == 'preserve':
|
if attrValue == 'preserve':
|
||||||
preserveWhitespace = True
|
preserveWhitespace = True
|
||||||
|
|
|
||||||
|
|
@ -945,6 +945,12 @@ class DoNotPrettyPrintWhenNestedWhitespacePreserved(unittest.TestCase):
|
||||||
</svg>''',
|
</svg>''',
|
||||||
'Whitespace not preserved when nested')
|
'Whitespace not preserved when nested')
|
||||||
|
|
||||||
|
class GetAttrPrefixRight(unittest.TestCase):
|
||||||
|
def runTest(self):
|
||||||
|
grad = scour.scourXmlFile('unittests/xml-namespace-attrs.svg').getElementsByTagNameNS(SVGNS, 'linearGradient')[1]
|
||||||
|
self.assertEquals( grad.getAttributeNS('http://www.w3.org/1999/xlink', 'href'), '#linearGradient841',
|
||||||
|
'Did not get xlink:href prefix right' )
|
||||||
|
|
||||||
# TODO; write a test for embedding rasters
|
# TODO; write a test for embedding rasters
|
||||||
# TODO: write a test for --disable-embed-rasters
|
# TODO: write a test for --disable-embed-rasters
|
||||||
# TODO: write tests for --keep-editor-data
|
# TODO: write tests for --keep-editor-data
|
||||||
|
|
|
||||||
24
unittests/xml-namespace-attrs.svg
Normal file
24
unittests/xml-namespace-attrs.svg
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="256pt" height="3170.0000pt">
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="linearGradient841">
|
||||||
|
<stop id="stop842" offset="0.00000000" style="stop-color:#0082ab;stop-opacity:1;"/>
|
||||||
|
<stop id="stop843" offset="1" style="stop-color:white;stop-opacity:0;"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient y2="0.91666669" x2="0.51618570" y1="0.16666391" x1="0.51618570" id="linearGradient1657" xlink:href="#linearGradient841"/>
|
||||||
|
</defs>
|
||||||
|
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="linearGradient841">
|
||||||
|
<stop style="stop-color:#0082ab;stop-opacity:1;" offset="0.00000000" id="stop842"/>
|
||||||
|
<stop style="stop-color:white;stop-opacity:0;" offset="1" id="stop843"/>
|
||||||
|
</linearGradient>
|
||||||
|
<linearGradient xlink:href="#linearGradient841" id="linearGradient2465" x1="76.846634" y1="-7656.4473" x2="76.846633" y2="-7528.6605" gradientTransform="matrix(2.149642,0.000000,0.000000,0.465194,-0.130153,3495.428)" gradientUnits="userSpaceOnUse"/>
|
||||||
|
</defs>
|
||||||
|
|
||||||
|
<rect height="50" width="50" fill="url(#linearGradient841)"/>
|
||||||
|
<rect height="69.247704" width="319.89233" fill="url(#linearGradient1657)"/>
|
||||||
|
<rect fill="url(#linearGradient2465)" width="319.99103" height="69.247704"/>
|
||||||
|
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.3 KiB |
Loading…
Add table
Add a link
Reference in a new issue