From f6fed94d79013c9180dbdb0b0bedef6fd8843a42 Mon Sep 17 00:00:00 2001 From: Klaus Thoden Date: Fri, 31 Aug 2018 18:11:35 +0200 Subject: [PATCH] Table number to tabdict and id handling --- tei2imxml.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tei2imxml.py b/tei2imxml.py index d24874e..ada4d85 100644 --- a/tei2imxml.py +++ b/tei2imxml.py @@ -662,6 +662,7 @@ def assign_ids(xml_tree, data): equation_counter = 1 footnote_counter = 1 list_counter = 1 + figure_counter = 1 section_counter = 1 table_counter = 1 theorem_counter = 1 @@ -671,7 +672,6 @@ def assign_ids(xml_tree, data): chapterdict[chapter.get("id")] = str(chapter_counter) figure_anchors = chapter.findall(".//EOAfigure/anchor") - figure_counter = 1 for anchor in figure_anchors: figure_number = "%d.%d" % (chapter_counter, figure_counter) @@ -687,7 +687,6 @@ def assign_ids(xml_tree, data): fndict[footnote.get("id")] = footnote.get("n") sections = chapter.findall(".//div2") - section_counter = 1 for section in sections: if section.get('rend') != "nonumber": @@ -705,6 +704,15 @@ def assign_ids(xml_tree, data): subsection_counter += 1 section_counter += 1 + + tables = chapter.findall(".//EOAtable/table") + for table in tables: + table_number = "{}.{}".format(chapter_counter, table_counter) + table.attrib["id-text"] = table_number + # table.set("id-text", table_number) + table_counter += 1 + tabdict[table.get("id")] = table_number + chapter_counter += 1 # not implemented yet: equation, list, pagelabel, tab, theorem @@ -727,9 +735,6 @@ def update_ids(xml_tree): xmlReferences = xml_tree.findall(".//EOAref") logging.debug("Found %d references", len(xmlReferences)) - all_ids = xml_tree.xpath('//*[@xml:id]') - for xmlid in all_ids: - print(xmlid, "all ids") for xmlReference in xmlReferences: eoa_reference = xmlReference.find("ref")