'@elem: The element in the etree that we are working on.
@stylizer: The style information attached to the element.'

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

    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 [u'']
    text = [u'']
    style = stylizer.style(elem)
    tags = []
    tag = barename(elem.tag)
    attribs = elem.attrib
    style_a = (u'%s' % style)
    style_a = (style_a if style_a else u'')
    if (tag == u'body'):
        tag = u'div'
        style_a = (u'page-break-before:    always;    %s' % re.sub(u'page-break-[^:]+:[^;]+;?', u'', style_a))
    style_a = re.sub(u'\\s{2,}', u'    ', style_a).strip()
    tags.append(tag)
    if (u'class' in attribs):
        del attribs[u'class']
    if (u'style' in attribs):
        del attribs[u'style']
    at = u''
    for (k, v) in attribs.items():
        at += (u'    %s="%s"' % (k, prepare_string_for_xml(v, attribute=True)))
    style_t = u''
    if style_a:
        style_t = (u'    style="%s"' % style_a.replace(u'"', u"'"))
    text.append((u'<%s%s%s' % (tag, at, style_t)))
    if (tag in SELF_CLOSING_TAGS):
        text.append(u'    />')
    else:
        text.append(u'>')
    if (hasattr(elem, u'text') and elem.text):
        text.append(self.prepare_string_for_html(elem.text))
    for item in elem:
        text += self.dump_text(item, stylizer, page)
    tags.reverse()
    for t in tags:
        if (t not in SELF_CLOSING_TAGS):
            text.append((u'</%s>' % t))
    if (hasattr(elem, u'tail') and elem.tail):
        text.append(self.prepare_string_for_html(elem.tail))
    return text
