code: def envelope(**kwargs):
      
      e_oaipmh = Element(etree.QName(NS_OAIPMH, 'OAI-PMH'), nsmap=NSMAP)
      e_oaipmh.set(etree.QName(NS_XSI, 'schemaLocation'),
                   '{0} {1}'.format(NS_OAIPMH, NS_OAIPMH_XSD))
      e_tree = ElementTree(element=e_oaipmh)
  
      if current_app.config['OAISERVER_XSL_URL']:
          e_oaipmh.addprevious(etree.ProcessingInstruction(
              'xml-stylesheet', 'type="text/xsl" href="{0}"'
                  .format(current_app.config['OAISERVER_XSL_URL'])))
  
      e_responseDate = SubElement(
          e_oaipmh, etree.QName(
              NS_OAIPMH, 'responseDate'))
      # date should be first possible moment
      e_responseDate.text = datetime_to_datestamp(datetime.utcnow())
      e_request = SubElement(e_oaipmh, etree.QName(NS_OAIPMH, 'request'))
      for key, value in kwargs.items():
          if key == 'from_' or key == 'until':
              value = datetime_to_datestamp(value)
          elif key == 'resumptionToken':
              value = value['token']
          e_request.set(key, value)
      e_request.text = url_for('invenio_oaiserver.response', _external=True)
      return e_tree, e_oaipmh
docs: Create OAI-PMH envelope for response.