'Repeat td elements according to their rowspan attributes
in subsequent tr elements.'

def preprocess_dom(self, dom):

    cols = self.xpath(dom, '//td[@rowspan]')
    for col in cols:
        span = int(col.get('rowspan'))
        del col.attrib['rowspan']
        position = len(self.xpath(col, './preceding-sibling::td'))
        row = col.getparent()
        for tr in self.xpath(row, './following-sibling::tr')[:(span - 1)]:
            clone = self.clone(col)
            tr.insert(position, clone)
    return dom
