diff --git a/src/eoatex2imxml.py b/src/eoatex2imxml.py index ce8584e..2c24f80 100755 --- a/src/eoatex2imxml.py +++ b/src/eoatex2imxml.py @@ -1066,7 +1066,9 @@ def number_tables( xmlChapters ): continue if not xmlTableLabel.text or xmlTableLabel.text == "": xmlTableLabel.text = "table" + str(intChapterNumber) + str(intTableNumber) - strUID = xmlTableLabel.text + # the question is vexed: label or id! + # strUID = xmlTableLabel.text + strUID = xml_table_id logging.debug(f"XML table label: {strUID}") if xmlChapter.get("rend") != "nonumber": dictTables[strUID] = dictChapters[xmlChapter.get('id')] + "." + str(intTableNumber) @@ -1086,7 +1088,12 @@ def process_references(xmlTree): target_attribute = ref.xpath("./ref/@target") ref_label = ref.find("./Label").text if not target_attribute: - the_label = xmlTree.xpath(f"//*[@place='{ref_label}']/@id")[0] + logging.debug(ref_label) + try: + the_label = xmlTree.xpath(f"//*[@place='{ref_label}']/@id")[0] + except IndexError: + ref_label = ref_label.replace("_", "") + the_label = xmlTree.xpath(f"//*[@place='{ref_label}']/@id")[0] ref_element.set("target", the_label) else: pass