Skip to content

Commit

Permalink
Observe only main index entry for keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
kthoden committed May 27, 2020
1 parent 5e7a4d3 commit 3c9bf32
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/tei2imxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1272,7 +1272,7 @@ def handle_refs_default(ref):
############
# Indexing #
############
index_entries = xml_tree.xpath("//t:body//t:index", namespaces=NS_MAP)
index_entries = xml_tree.xpath("//t:body//t:index[not(ancestor::t:index)]", namespaces=NS_MAP)
for entry in index_entries:
index_type = entry.get("indexName")
tagname = "EOAindex"
Expand All @@ -1281,13 +1281,19 @@ def handle_refs_default(ref):
entry.tag = tagname
entry_tail = entry.tail
entry_content = entry.find("t:term", namespaces=NS_MAP)
try:
sortkey = entry_content.get("sortKey")
except AttributeError:
sortkey = ""
entry_text = ""
if len(sortkey) > 0:

sortkey = entry_content.get("sortKey")
# try:
# sortkey = entry_content.get("sortKey")
# except AttributeError:
# sortkey = ""
if sortkey is None:
logging.info("No sortkey found")
else:
entry_text = f"{sortkey}@"
# if len(sortkey) > 0:
# entry_text = f"{sortkey}@"
# markup ignored for now
remainder = libeoaconvert.gettext(entry_content)
entry_text += remainder
Expand Down

0 comments on commit 3c9bf32

Please sign in to comment.