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(xml, func, uuid)

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

Parameters:
  • 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.
Returns:

List of string with postprocessed XML.

Return type:

list

marcxml2mods.transformators.transform_to_mods_mono(marc_xml, uuid)

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.
Returns:

Collection of transformed xml strings.

Return type:

list

marcxml2mods.transformators.transform_to_mods_multimono(marc_xml, uuid)

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.
Returns:

Collection of transformed xml strings.

Return type:

list

marcxml2mods.transformators.transform_to_mods_periodical(marc_xml, uuid)

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.
Returns:

Collection of transformed xml strings.

Return type:

list

marcxml2mods.transformators.marcxml2mods(marc_xml, uuid)

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.
Returns:

Collection of transformed xml strings.

Return type:

list