Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Table transformation
  • Loading branch information
Klaus Thoden committed Aug 31, 2018
1 parent 1bcd4e8 commit 69bce60
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tei2imxml.py
Expand Up @@ -114,6 +114,7 @@ def get_field(xml_tree, query_path, mandatory=False, findall=False):
info_dict['eoa_keywords'] = get_field(xml_tree, "//t:teiHeader/t:profileDesc/t:textClass/t:keywords/t:list/t:item", findall=True)
info_dict['eoa_authors'] = get_field(xml_tree, "//t:teiHeader/t:fileDesc/t:titleStmt/t:author", findall=True)
info_dict['eoa_editors'] = get_field(xml_tree, "//t:teiHeader/t:fileDesc/t:titleStmt/t:editor", findall=True)

return info_dict
# def get_publication_info ends here

Expand Down Expand Up @@ -576,9 +577,7 @@ def transform_body(xml_tree, cited_data, publang):
number_of_cells = len(table.findall("t:row[1]/t:cell", namespaces=NS_MAP))

if table_caption is not None:
# print(etree.tostring(table))
table_id = table.attrib["{http://www.w3.org/XML/1998/namespace}id"]
# table_id = table.get("{httbp://www.w3.org/XML/1998/namespace}id")
table.clear()
table_label = etree.Element("EOAtablelabel")
table_label.text = table_id
Expand All @@ -590,24 +589,22 @@ def transform_body(xml_tree, cited_data, publang):
table.clear()
# not sure if this is evaluated later.
table_label = etree.SubElement(table, "EOAtablecolumns").text = "L3cm" * number_of_cells
real_table_element = etree.SubElement(table, "table")

if table_caption is not None:
table.insert(1, table_caption)
real_table_element.set("place", table_id)
real_table_element.attrib["{http://www.w3.org/XML/1998/namespace}id"] = table_id
else:
pass

real_table_element = etree.SubElement(table, "table")
real_table_element.set("place", table_id)
real_table_element.set("rend", "display")
# how are those two constructed?
real_table_element.set("id-text", "1")
real_table_element.set("id", "uid38")
# attributes id-text and id are assigned later

for row in tablechildren:
if row.get("role") == "label":
tableheader = etree.Element("tableheader")
tableheader.text = "TRUE"
# <tableheader>TRUE</tableheader>
row.insert(0, tableheader)
else:
pass
Expand Down

0 comments on commit 69bce60

Please sign in to comment.