'This function is intended to be used in a recursive manner. dump_text will
run though all elements in the elem_tree and call itself on each element.
self.image_hrefs will be populated by calling this function.
@param elem_tree: etree representation of XHTML content to be transformed.
@param stylizer: Used to track the style of elements within the tree.
@param page: OEB page used to determine absolute urls.
@param tag_stack: List of open FB2 tags to take into account.
@return: List of string representing the XHTML converted to FB2 markup.'

def dump_text(self, elem_tree, stylizer, page, tag_stack=[]):

    from calibre.ebooks.oeb.base import XHTML_NS, barename, namespace
    elem = elem_tree
    if ((not isinstance(elem_tree.tag, basestring)) or (namespace(elem_tree.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 []
    style = stylizer.style(elem_tree)
    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 []
    fb2_out = []
    tags = []
    tag = barename(elem_tree.tag)
    try:
        ems = int(round(((float(style.marginTop) / style.fontSize) - 1)))
        if (ems < 0):
            ems = 0
    except:
        ems = 0
    if (self.opts.sectionize == 'toc'):
        if (not tag_stack):
            newlevel = 0
            toc_entry = self.toc.get(page.href, None)
            if (toc_entry is not None):
                if (None in toc_entry):
                    if ((tag != 'body') and hasattr(elem_tree, 'text') and elem_tree.text):
                        newlevel = 1
                        self.toc[page.href] = None
                if ((not newlevel) and (elem_tree.attrib.get('id', None) is not None)):
                    newlevel = toc_entry.get(elem_tree.attrib.get('id', None), None)
            if newlevel:
                while (newlevel <= self.section_level):
                    fb2_out.append('</section>')
                    self.section_level -= 1
                fb2_out.append('<section>')
                self.section_level += 1
                fb2_out.append('<title>')
                tags.append('title')
        if (self.section_level == 0):
            fb2_out.append('<section>')
            self.section_level += 1
    if (tag == 'img'):
        if elem_tree.attrib.get('src', None):
            ihref = urlnormalize(page.abshref(elem_tree.attrib['src']))
            if (ihref in self.oeb_book.manifest.hrefs):
                if (ihref not in self.image_hrefs):
                    self.image_hrefs[ihref] = ('_%s.jpg' % len(self.image_hrefs))
                (p_txt, p_tag) = self.ensure_p()
                fb2_out += p_txt
                tags += p_tag
                fb2_out.append(('<image    xlink:href="#%s"    />' % self.image_hrefs[ihref]))
            else:
                self.log.warn((u'Ignoring    image    not    in    manifest:    %s' % ihref))
    if ((tag in ('br', 'hr')) or (ems >= 1)):
        if (ems < 1):
            multiplier = 1
        else:
            multiplier = ems
        if self.in_p:
            closed_tags = []
            open_tags = (tag_stack + tags)
            open_tags.reverse()
            for t in open_tags:
                fb2_out.append(('</%s>' % t))
                closed_tags.append(t)
                if (t == 'p'):
                    break
            fb2_out.append(('<empty-line    />' * multiplier))
            closed_tags.reverse()
            for t in closed_tags:
                fb2_out.append(('<%s>' % t))
        else:
            fb2_out.append(('<empty-line    />' * multiplier))
    if (tag in ('div', 'li', 'p')):
        (p_text, added_p) = self.close_open_p((tag_stack + tags))
        fb2_out += p_text
        if added_p:
            tags.append('p')
    if ((tag == 'b') or (style['font-weight'] in ('bold', 'bolder'))):
        (s_out, s_tags) = self.handle_simple_tag('strong', (tag_stack + tags))
        fb2_out += s_out
        tags += s_tags
    if ((tag == 'i') or (style['font-style'] == 'italic')):
        (s_out, s_tags) = self.handle_simple_tag('emphasis', (tag_stack + tags))
        fb2_out += s_out
        tags += s_tags
    if ((tag in ('del', 'strike')) or (style['text-decoration'] == 'line-through')):
        (s_out, s_tags) = self.handle_simple_tag('strikethrough', (tag_stack + tags))
        fb2_out += s_out
        tags += s_tags
    if (tag == 'sub'):
        (s_out, s_tags) = self.handle_simple_tag('sub', (tag_stack + tags))
        fb2_out += s_out
        tags += s_tags
    if (tag == 'sup'):
        (s_out, s_tags) = self.handle_simple_tag('sup', (tag_stack + tags))
        fb2_out += s_out
        tags += s_tags
    if (hasattr(elem_tree, 'text') and elem_tree.text):
        if (not self.in_p):
            fb2_out.append('<p>')
        fb2_out.append(prepare_string_for_xml(elem_tree.text))
        if (not self.in_p):
            fb2_out.append('</p>')
    for item in elem_tree:
        fb2_out += self.dump_text(item, stylizer, page, (tag_stack + tags))
    tags.reverse()
    fb2_out += self.close_tags(tags)
    if (hasattr(elem_tree, 'tail') and elem_tree.tail):
        if (not self.in_p):
            fb2_out.append('<p>')
        fb2_out.append(prepare_string_for_xml(elem_tree.tail))
        if (not self.in_p):
            fb2_out.append('</p>')
    return fb2_out
