scour.py: handle id' and xml:id' in the same code for other attributes
This commit is contained in:
parent
377a339263
commit
95b1df843f
1 changed files with 1 additions and 18 deletions
|
|
@ -3215,26 +3215,11 @@ def serializeXML(element, options, ind=0, preserveWhitespace=False):
|
||||||
|
|
||||||
outParts.extend([(I * ind), '<', element.nodeName])
|
outParts.extend([(I * ind), '<', element.nodeName])
|
||||||
|
|
||||||
# always serialize the id or xml:id attributes first
|
|
||||||
id = element.getAttribute('id')
|
|
||||||
if id != '':
|
|
||||||
quot = '"'
|
|
||||||
if id.find('"') != -1:
|
|
||||||
quot = "'"
|
|
||||||
outParts.extend([' id=', quot, id, quot])
|
|
||||||
|
|
||||||
id = element.getAttribute('xml:id')
|
|
||||||
if id != '':
|
|
||||||
quot = '"'
|
|
||||||
if id.find('"') != -1:
|
|
||||||
quot = "'"
|
|
||||||
outParts.extend([' xml:id=', quot, id, quot])
|
|
||||||
|
|
||||||
# now serialize the other attributes
|
# now serialize the other attributes
|
||||||
known_attr = [
|
known_attr = [
|
||||||
# TODO: Maybe update with full list from https://www.w3.org/TR/SVG/attindex.html
|
# TODO: Maybe update with full list from https://www.w3.org/TR/SVG/attindex.html
|
||||||
# (but should be kept inuitively ordered)
|
# (but should be kept inuitively ordered)
|
||||||
'id', 'class',
|
'id', 'xml:id', 'class',
|
||||||
'transform',
|
'transform',
|
||||||
'x', 'y', 'z', 'width', 'height', 'x1', 'x2', 'y1', 'y2',
|
'x', 'y', 'z', 'width', 'height', 'x1', 'x2', 'y1', 'y2',
|
||||||
'dx', 'dy', 'rotate', 'startOffset', 'method', 'spacing',
|
'dx', 'dy', 'rotate', 'startOffset', 'method', 'spacing',
|
||||||
|
|
@ -3254,8 +3239,6 @@ def serializeXML(element, options, ind=0, preserveWhitespace=False):
|
||||||
attrIndices += [attrName2Index[name] for name in sorted(attrName2Index.keys())]
|
attrIndices += [attrName2Index[name] for name in sorted(attrName2Index.keys())]
|
||||||
for index in attrIndices:
|
for index in attrIndices:
|
||||||
attr = attrList.item(index)
|
attr = attrList.item(index)
|
||||||
if attr.nodeName == 'id' or attr.nodeName == 'xml:id':
|
|
||||||
continue
|
|
||||||
# if the attribute value contains a double-quote, use single-quotes
|
# if the attribute value contains a double-quote, use single-quotes
|
||||||
quot = '"'
|
quot = '"'
|
||||||
if attr.nodeValue.find('"') != -1:
|
if attr.nodeValue.find('"') != -1:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue