diff --git a/eoatex2imxml.py b/eoatex2imxml.py index 831bec9..1aae864 100755 --- a/eoatex2imxml.py +++ b/eoatex2imxml.py @@ -1610,22 +1610,26 @@ def cleanup(): # here followed the conversion to epub and the conversion to django.xml # both parts were removed and put into separate files. +intermediate_file_pre = "tmp_files/IntermediateXMLFile_pre.xml" intermediate_file = "tmp_files/IntermediateXMLFile.xml" -ergebnisdatei = open(intermediate_file, "w") +ergebnisdatei = open(intermediate_file_pre, "w") ergebnis = etree.tostring(xmlTree, pretty_print=True, encoding="unicode") ergebnisdatei.write(ergebnis) ergebnisdatei.close() # replacing a milestone element by a closing and opening combination -with open(intermediate_file, 'r') as tmp_file: +with open(intermediate_file_pre, 'r') as tmp_file: filedata = tmp_file.read() +# add XML declaration +filedata_declaration = "\n" + filedata + # Replace the target string -filedata = filedata.replace('', '

') +filedata_clean = filedata_declaration.replace('', '

') # Write the file out again with open(intermediate_file, 'w') as outfile: - outfile.write(filedata) + outfile.write(filedata_clean) # saving some data data_to_pickle = {'chapterdict' : dictChapters,