Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
References
  • Loading branch information
Klaus Thoden committed May 29, 2018
1 parent 39f748a commit 3e07e8c
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tei2imxml.py
Expand Up @@ -543,6 +543,32 @@ def transform_body(xml_tree, cited_data, publang):
else:
logging.info("The rend attribute in hi has the value %s. This is not supported" % rend_attribute)

##############
# References #
##############
eoa_ref = xml_tree.xpath("//t:body//t:ref", namespaces=NS_MAP)

for ref in eoa_ref:
ref_parent = ref.getparent()
if ref_parent == "bibl":
continue
target_attribute = ref.get("target")
if len(target_attribute) == 0:
print("Found a ref element without target. Exiting.")
sys.exit()
else:
url_attribute = ref.get("type")
if url_attribute == "url":
del ref.attrib["type"]
del ref.attrib["target"]
ref.tag = "xref"
ref.set("url", target_attribute)
else:
ref.tag = "EOAref"
del ref.attrib["target"]
etree.SubElement(ref, "ref", teitarget=target_attribute)
etree.SubElement(ref, "Label").text = target_attribute

return xml_tree
# def transform_body ends here

Expand Down

0 comments on commit 3e07e8c

Please sign in to comment.