docs: def adapt_item(item, package, filename=None):
      """Adapts ``.epub.Item`` to a ``DocumentItem``.
  
      """
      if item.media_type == 'application/xhtml+xml':
          try:
              html = etree.parse(item.data)
          except Exception as exc:
              logger.error("failed parsing {}".format(item.name))
              raise
          metadata = DocumentPointerMetadataParser(
              html, raise_value_error=False)()
          item.data.seek(0)
          if metadata.get('is_document_pointer'):
              model = DocumentPointerItem(item, package)
          else:
              model = DocumentItem(item, package)
      else:
          model = Resource(item.name, item.data, item.media_type,
                           filename or item.name)
      return model