From 1aad91bd66c99513cb8d866767c18bb5e575cf28 Mon Sep 17 00:00:00 2001 From: kthoden Date: Tue, 30 Jul 2019 11:32:47 +0200 Subject: [PATCH] Footnotes without IDs are dangerous --- tei2imxml.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tei2imxml.py b/tei2imxml.py index 4297040..c76ed1f 100755 --- a/tei2imxml.py +++ b/tei2imxml.py @@ -618,7 +618,11 @@ def handle_refs_hyperimage(ref): fn_parent = footnote.getparent() # we assert here that the parent of a footnote is always a paragraph or a quote - footnote_id = footnote.xpath("@xml:id")[0] + try: + footnote_id = footnote.xpath("@xml:id")[0] + except IndexError: + logging.error("Found footnote without xml:id. Exiting.") + sys.exit(1) # logging.debug(f"The prefix of fn_parent is {fn_parent.prefix}.")