Skip to content

Commit

Permalink
improvement of the indentation of the xml output by appending childre…
Browse files Browse the repository at this point in the history
…n nodes into their respective parent nodes
  • Loading branch information
Mazztok45 committed Dec 6, 2023
1 parent 2ab6965 commit e75c519
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/zbmath_rest2oai/getWithSwagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ def func_get_doc_to_xml(obj, xml):
elif obj[i] is None:
xml = append_text_child(xmld, xml, xml.lastChild.nodeName, 'missing')
elif type(obj[i]) in [str,int]:
xml = append_text_child(xmld, xml, xml.lastChild.nodeName, obj[i])
parent_name = xml.lastChild.nodeName
if parent_name.endswith('s'):
parent_name = parent_name[:-1]

if xml._get_lastChild().nodeName == parent_name:
xml = append_text_child(xmld, xml, parent_name, obj[i])
else:
xml = append_text_child(xmld, xml._get_lastChild(), parent_name, obj[i])
elif type(obj[i]) in all_iter_list:
func_get_doc_to_xml(obj[i], xml)
else:
Expand All @@ -94,10 +101,8 @@ def func_get_doc_to_xml(obj, xml):
func_get_doc_to_xml(obj[key], xml)
return xml

print(func_get_doc_to_xml(res.result, ron).toprettyxml())



final_xml = func_get_doc_to_xml(res.result, ron)

print(final_xml.toprettyxml())


0 comments on commit e75c519

Please sign in to comment.