transformators submodule

This module is used to transform Marc XML from Aleph to MODS. MODS is defined by XSLT templates.

marcxml2mods.transformators._absolute_template_path(fn)

Return absolute path for filename from local xslt/ directory.

Parameters:fn (str) – Filename. MARC21slim2MODS3-4-NDK.xsl for example.
Returns:Absolute path to fn in xslt dicretory..
Return type:str
marcxml2mods.transformators._apply_postprocessing(marc_xml, xml, func, uuid, url)

Apply func to all <mods:mods> tags from xml. Insert UUID.

Parameters:
  • marc_xml (str) – Original Aleph record.
  • xml (str) – XML which will be postprocessed.
  • func (fn) – Function, which will be used for postprocessing.
  • uuid (str) – UUID, which will be inserted to xml.
  • url (str) – URL of the publication (public or not).
Returns:

List of string with postprocessed XML.

Return type:

list

marcxml2mods.transformators.transform_to_mods_mono(marc_xml, uuid, url)

Convert marc_xml to MODS data format.

Parameters:
  • marc_xml (str) – Filename or XML string. Don’t use \n in case of filename.
  • uuid (str) – UUID string giving the package ID.
  • url (str) – URL of the publication (public or not).
Returns:

Collection of transformed xml strings.

Return type:

list

marcxml2mods.transformators.transform_to_mods_multimono(marc_xml, uuid, url)

Convert marc_xml to multimonograph MODS data format.

Parameters:
  • marc_xml (str) – Filename or XML string. Don’t use \n in case of filename.
  • uuid (str) – UUID string giving the package ID.
  • url (str) – URL of the publication (public or not).
Returns:

Collection of transformed xml strings.

Return type:

list

marcxml2mods.transformators.transform_to_mods_periodical(marc_xml, uuid, url)

Convert marc_xml to periodical MODS data format.

Parameters:
  • marc_xml (str) – Filename or XML string. Don’t use \n in case of filename.
  • uuid (str) – UUID string giving the package ID.
  • url (str) – URL of the publication (public or not).
Returns:

Collection of transformed xml strings.

Return type:

list

marcxml2mods.transformators.type_decisioner(marc_xml, mono_callback, multimono_callback, periodical_callback)

Detect type of the marc_xml. Call proper callback.

Parameters:
  • marc_xml (str) – Filename or XML string. Don’t use \n in case of filename.
  • mono_callback (fn reference) – Callback in case of monographic publications.
  • multimono_callback (fn reference) – Callback used in case of multi-monographic publications.
  • periodical_callback (fn reference) – Callback used in case of periodical publications.
Returns:

Content returned by the callback.

Return type:

obj

Raises:

ValueError – In case that type couldn’t be detected.

marcxml2mods.transformators.marcxml2mods(marc_xml, uuid, url)

Convert marc_xml to MODS. Decide type of the record and what template to use (monograph, multi-monograph, periodical).

Parameters:
  • marc_xml (str) – Filename or XML string. Don’t use \n in case of filename.
  • uuid (str) – UUID string giving the package ID.
  • url (str) – URL of the publication (public or not).
Returns:

Collection of transformed xml strings.

Return type:

list