IGN:Prefer name to id when they differ during splitting. Also use first rather than last occurrence of an id.

This commit is contained in:
Kovid Goyal 2009-08-20 09:10:28 -06:00
parent bdb0da92f8
commit 5ab558aca6

View File

@ -457,9 +457,8 @@ class FlowSplitter(object):
root = tree.getroot() root = tree.getroot()
self.files.append(self.base%i) self.files.append(self.base%i)
for elem in root.xpath('//*[@id or @name]'): for elem in root.xpath('//*[@id or @name]'):
anchor = elem.get('id', '') for anchor in elem.get('id', ''), elem.get('name', ''):
if not anchor: if anchor != '' and anchor not in self.anchor_map:
anchor = elem.get('name')
self.anchor_map[anchor] = self.files[-1] self.anchor_map[anchor] = self.files[-1]
for elem in root.xpath('//*[@%s]'%SPLIT_POINT_ATTR): for elem in root.xpath('//*[@%s]'%SPLIT_POINT_ATTR):
elem.attrib.pop(SPLIT_POINT_ATTR, '0') elem.attrib.pop(SPLIT_POINT_ATTR, '0')