xslt_transformer submodule¶
This module is used to transform XML using XSLT templates.
API¶
-
marcxml2mods.xslt_transformer.
_oai_to_xml
(marc_oai)¶ Convert OAI to MARC XML.
Parameters: marc_oai (str) – String with either OAI or MARC XML. Returns: String with MARC XML. Return type: str
-
marcxml2mods.xslt_transformer.
_add_namespace
(marc_xml)¶ Add proper XML namespace to the marc_xml record.
Parameters: marc_xml (str) – String representation of the XML record. Returns: XML with namespace. Return type: str
-
marcxml2mods.xslt_transformer.
_read_content_or_path
(content_or_path)¶ If content_or_path contains
\n
, return it. Else assume, that it is path and read file at that path.Parameters: content_or_path (str) – Content or path to the file. Returns: Content. Return type: str Raises: IOError
– whhen the file is not found.
-
marcxml2mods.xslt_transformer.
_read_marcxml
(xml)¶ Read MARC XML or OAI file, convert, add namespace and return XML in required format with all necessities.
Parameters: xml (str) – Filename or XML string. Don’t use \n
in case of filename.Returns: Required XML parsed with lxml.etree
.Return type: obj
-
marcxml2mods.xslt_transformer.
_read_template
(template)¶ Read XSLT template.
Parameters: template (str) – Filename or XML string. Don’t use \n
in case of filename.Returns: Required XML parsed with lxml.etree
.Return type: obj
-
marcxml2mods.xslt_transformer.
xslt_transformation
(xml, template)¶ Transform xml using XSLT template.
Parameters: Returns: Transformed xml as string.
Return type: