Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Authors and editors
  • Loading branch information
Klaus Thoden committed May 29, 2018
1 parent dfe0b4d commit 0338824
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions tei2imxml.py
Expand Up @@ -295,9 +295,37 @@ def format_pagerange(pagerange_start, pagerange_end):
return return_string
# def format_pagerange ends here

def transform_body(xml_tree, cited_data, authors, publang):
"""Transform the body of XML document into EOADjango file"""
def format_authors(list_author_id, publang):
"""Retrieve author names from respStmt entries and format them."""

author_string = ""

formatted_list = []

for author in list_author_id:
tmp_xpath = "//t:respStmt[@xml:id='%s']" % author[1:]
author_xml = xml_tree.xpath(tmp_xpath, namespaces=NS_MAP)

surname = author_xml[0].find("t:persName/t:surname", namespaces=NS_MAP).text
forename = author_xml[0].find("t:persName/t:forename", namespaces=NS_MAP).text

single_author_string = "{} {}".format(forename, surname)
formatted_list.append(single_author_string)

if len(formatted_list) == 1:
author_string = formatted_list[0]
elif len(formatted_list) == 2:
author_string = "{} {} {}".format(formatted_list[0], libeoaconvert.dict_and[publang], formatted_list[1])
elif len(formatted_list) > 2:
author_string = ", ".join(formatted_list[0:-1])
author_string += " {} {}".format(libeoaconvert.dict_and[publang], formatted_list[-1])
return author_string
# def format_authors ends here

def transform_body(xml_tree, cited_data, publang):
"""Transform the body of XML document into IntermediateXML file"""

logging.info("Performing XML transformations of the body.")
######################
# Document structure #
######################
Expand Down

0 comments on commit 0338824

Please sign in to comment.