diff --git a/src/tei2imxml.py b/src/tei2imxml.py index ef4f1ad..04940be 100755 --- a/src/tei2imxml.py +++ b/src/tei2imxml.py @@ -659,6 +659,15 @@ def resolve_choice_to_expan(element_containing_choice, original_element): def transform_body(xml_tree, cited_data, translation_file, template_path, xml_hyperimagexml_code, olddesign, publang, temp_dir, output_dir, hyperimage=False): """Transform the body of XML document into IntermediateXML file""" + def convert_n_to_rend(div_element): + """Convert n attribute to rend attribute""" + + n_value = div_element.get("n") + if n_value == "nonumber": + div_element.set("rend", "nonumber") + # def convert_n_to_rend end here + + def retain_original_contents(ref): """Store original contents in a separate element""" @@ -796,9 +805,10 @@ def handle_refs_default(ref): for chapter in eoa_chapters: chapter.tag = "div1" chapter.set("language", publang) - n_value = chapter.get("n") - if n_value == "nonumber": - chapter.set("rend", "nonumber") + convert_n_to_rend(chapter) + # n_value = chapter.get("n") + # if n_value == "nonumber": + # chapter.set("rend", "nonumber") # del chapter.attrib["n"] chapter_title_element = chapter.find("t:head", namespaces=NS_MAP) @@ -820,6 +830,8 @@ def handle_refs_default(ref): eoa_sections = xml_tree.xpath("//t:div[@type='section']", namespaces=NS_MAP) for section in eoa_sections: section.tag = "div2" + convert_n_to_rend(section) + eoa_milestones = xml_tree.xpath("//t:milestone[@type='divider']", namespaces=NS_MAP) for milestone in eoa_milestones: @@ -830,10 +842,12 @@ def handle_refs_default(ref): eoa_subsections = xml_tree.xpath("//t:div[@type='subsection']", namespaces=NS_MAP) for subsection in eoa_subsections: subsection.tag = "div3" + convert_n_to_rend(subsection) eoa_subsubsections = xml_tree.xpath("//t:div[@type='subsubsection']", namespaces=NS_MAP) for subsubsection in eoa_subsubsections: subsubsection.tag = "div4" + convert_n_to_rend(subsubsection) ############## # Paragraphs # @@ -1470,7 +1484,7 @@ def assign_ids(xml_tree, data, suppress_chapter_number): def update_ids(xml_tree, ignore_ref_errors): """Update the references in EOAref to the id value assigned in assign_ids""" - xmlReferences = xml_tree.findall(".//EOAref") + xmlReferences = xml_tree.xpath(".//EOAref|.//EOApageref") logging.debug("Found %d references", len(xmlReferences)) for xmlReference in xmlReferences: