diff --git a/imxml2django.py b/imxml2django.py index 6c73051..64a437e 100755 --- a/imxml2django.py +++ b/imxml2django.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8; mode: python -*- -# Time-stamp: <2018-09-13 15:15:48 (kthoden)> +# Time-stamp: <2019-02-15 15:23:43 (kthoden)> """ Create an XML file that can be inserted into the Django database @@ -639,13 +639,17 @@ def djangoParseObject(xmlElement, indent=False, listtype=None, listnumber=0, uid # throw them out for the time being xmlResult = etree.Element("temp") else: - xmlElement.tag = "EOAparagraph" - quoted_paragraph = xmlElement.get("rend") - if quoted_paragraph is not None and quoted_paragraph == "quoted": - xmlElement.set("rend", "quoted") - xmlElement.set("order", str(intObjectNumber)) - intObjectNumber += 1 - xmlResult = xmlElement + if xmlElement.getchildren() == [] and not xmlElement.text: + logging.debug(f"Removing empty paragraph") + xmlResult = etree.Element("temp") + else: + xmlElement.tag = "EOAparagraph" + quoted_paragraph = xmlElement.get("rend") + if quoted_paragraph is not None and quoted_paragraph == "quoted": + xmlElement.set("rend", "quoted") + xmlElement.set("order", str(intObjectNumber)) + intObjectNumber += 1 + xmlResult = xmlElement else: print("SPECIAL: %s - %s" % (xmlElement, xmlElement.text)) xmlResult = xmlElement