From c1adcb93ee40cf690feb0364e09ae6c6480b8c22 Mon Sep 17 00:00:00 2001
From: Patrick Jentsch <p.jentsch@uni-bielefeld.de>
Date: Wed, 29 Jan 2020 13:57:38 +0100
Subject: [PATCH] insert null values instead of empty attributes

---
 app/models.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/app/models.py b/app/models.py
index e3b6c1cf..5c6966dd 100644
--- a/app/models.py
+++ b/app/models.py
@@ -403,17 +403,17 @@ class CorpusFile(db.Model):
                             self.dir, self.filename)
         element_tree = ET.parse(file)
         text_node = element_tree.find('text')
-        text_node.set('address', self.address)
+        text_node.set('address', self.address if self.address else "NULL")
         text_node.set('author', self.author)
-        text_node.set('booktitle', self.booktitle)
-        text_node.set('chapter', self.chapter)
-        text_node.set('editor', self.editor)
-        text_node.set('institution', self.institution)
-        text_node.set('journal', self.journal)
-        text_node.set('pages', self.pages)
-        text_node.set('publisher', self.publisher)
+        text_node.set('booktitle', self.booktitle if self.booktitle else "NULL")
+        text_node.set('chapter', self.chapter if self.chapter else "NULL")
+        text_node.set('editor', self.editor if self.editor else "NULL")
+        text_node.set('institution', self.institution if self.institution else "NULL")
+        text_node.set('journal', self.journal if self.journal else "NULL")
+        text_node.set('pages', self.pages if self.pages else "NULL")
+        text_node.set('publisher', self.publisher if self.publisher else "NULL")
         text_node.set('publishing_year', str(self.publishing_year))
-        text_node.set('school', self.school)
+        text_node.set('school', self.school if self.school else "NULL")
         text_node.set('title', self.title)
         element_tree.write(file)
         self.corpus.status = 'unprepared'
-- 
GitLab