'@elem: The element in the etree that we are working on.
@stylizer: The style information attached to the element.
@page: OEB page used to determine absolute urls.'

def dump_text(self, elem, stylizer, page):

    from calibre.ebooks.oeb.base import XHTML_NS, barename, namespace
    if ((not isinstance(elem.tag, basestring)) or (namespace(elem.tag) != XHTML_NS)):
        p = elem.getparent()
        if ((p is not None) and isinstance(p.tag, basestring) and (namespace(p.tag) == XHTML_NS) and elem.tail):
            return [elem.tail]
        return ['']
    text = ['']
    style = stylizer.style(elem)
    if ((style['display'] in ('none', 'oeb-page-head', 'oeb-page-foot')) or (style['visibility'] == 'hidden')):
        if (hasattr(elem, 'tail') and elem.tail):
            return [elem.tail]
        return ['']
    tag = barename(elem.tag)
    tag_id = elem.attrib.get('id', None)
    in_block = False
    in_heading = False
    if ((tag in HEADING_TAGS) or (('%s#%s' % (page.href, tag_id)) in self.toc_ids)):
        in_heading = True
        if (not self.last_was_heading):
            text.append('\n\n\n\n\n\n')
    if ((tag in BLOCK_TAGS) or (style['display'] in BLOCK_STYLES)):
        if (self.opts.remove_paragraph_spacing and (not in_heading)):
            text.append(u' DCTB ')
        in_block = True
    if (tag in SPACE_TAGS):
        text.append(u'    ')
    if (tag == 'hr'):
        text.append('\n\n*    *    *\n\n')
    try:
        ems = int(round(((float(style.marginTop) / style.fontSize) - 1)))
        if (ems >= 1):
            text.append(('\n' * ems))
    except:
        pass
    if (hasattr(elem, 'text') and elem.text):
        text.append(elem.text)
    for item in elem:
        text += self.dump_text(item, stylizer, page)
    if in_block:
        text.append(u'\n\n')
    if in_heading:
        text.append(u'\n')
        self.last_was_heading = True
    else:
        self.last_was_heading = False
    if (hasattr(elem, 'tail') and elem.tail):
        text.append(elem.tail)
    return text
