'Serialize the href attribute of an <a> or <reference> tag. It is
serialized as filepos="000000000" and a pointer to its location is
stored in self.href_offsets so that the correct value can be filled in
at the end.'

def serialize_href(self, href, base=None):

    hrefs = self.oeb.manifest.hrefs
    try:
        (path, frag) = urldefrag(urlnormalize(href))
    except ValueError:
        return False
    if (path and base):
        path = base.abshref(path)
    if (path and (path not in hrefs)):
        return False
    buf = self.buf
    item = (hrefs[path] if path else None)
    if (item and (item.spine_position is None)):
        return False
    path = (item.href if item else base.href)
    href = (u'#'.join((path, frag)) if frag else path)
    buf.write('filepos=')
    self.href_offsets[href].append(buf.tell())
    buf.write('0000000000')
    return True
