docs: def _output_marc(output_complete, categories,
                   kw_field=None,
                   auth_field=None,
                   acro_field=None,
                   provenience='Classifier'):
      """Output the keywords in the MARCXML format.
  
      :var skw_matches: list of single keywords
      :var ckw_matches: list of composite keywords
      :var author_keywords: dictionary of extracted author keywords
      :var acronyms: dictionary of acronyms
      :var spires: boolean, True=generate spires output - BUT NOTE: it is
              here only not to break compatibility, in fact spires output
              should never be used for xml because if we read marc back
              into the KeywordToken objects, we would not find them
      :keyword provenience: string that identifies source (authority) that
          assigned the contents of the field
      :return: string, formatted MARC
      """
      if kw_field is None:
          kw_field = current_app.config["CLASSIFIER_RECORD_KEYWORD_FIELD"]
  
      if auth_field is None:
          auth_field = current_app.config[
              "CLASSIFIER_RECORD_KEYWORD_AUTHOR_FIELD"
          ]
  
      if acro_field is None:
          acro_field = current_app.config[
              "CLASSIFIER_RECORD_KEYWORD_ACRONYM_FIELD"
          ]
  
      kw_template = ('<datafield tag="%s" ind1="%s" ind2="%s">\n'
                     '    <subfield code="2">%s</subfield>\n'
                     '    <subfield code="a">%s</subfield>\n'
                     '    <subfield code="n">%s</subfield>\n'
                     '    <subfield code="9">%s</subfield>\n'
                     '</datafield>\n')
  
      output = []
  
      tag, ind1, ind2 = _parse_marc_code(kw_field)
      for keywords in (output_complete["single_keywords"],
                       output_complete["core_keywords"]):
          for kw in keywords:
              output.append(kw_template % (tag, ind1, ind2,
                                           encode_for_xml(provenience),
                                           encode_for_xml(kw), keywords[kw],
                                           encode_for_xml(categories[kw])))
  
      author_keywords = [keyword['author_keyword'] for keyword in
                         output_complete["author_keywords"]]
  
      for field, keywords in ((auth_field, author_keywords),
                              (acro_field, output_complete["acronyms"])):
          # field='' we shall not save the keywords
          if keywords and len(keywords) and field:
              tag, ind1, ind2 = _parse_marc_code(field)
              for kw, info in keywords.items():
                  output.append(kw_template % (tag, ind1, ind2,
                                               encode_for_xml(provenience),
                                               encode_for_xml(kw), '',
                                               encode_for_xml(categories[kw])))
  
      return "".join(output)