Improve remove empty paragraph.
[gpl/argeo-suite.git] / publishing / org.argeo.publishing.ui / src / org / argeo / docbook / DbkUtils.java
index b654c73178646597e50badabdbe2c6e13989a725..6db73d0e5b8a28b525f00c6fac789a9a3b00ce4d 100644 (file)
@@ -115,15 +115,21 @@ public class DbkUtils {
                try {
                        if (isDbk(node, DbkType.para)) {
                                NodeIterator nit = node.getNodes();
-                               if (!nit.hasNext())
-                                       return false;// log this unexpected situation?
+                               if (!nit.hasNext()) {
+                                       node.remove();
+                                       return true;
+                               }
                                Node first = nit.nextNode();
                                if (nit.hasNext())
                                        return false;
-                               String str = JcrxApi.getXmlValue(first);
-                               if (str != null && str.trim().equals("")) {
-                                       node.remove();
-                                       return true;
+                               if (first.getName().equals(Jcr.JCR_XMLTEXT)) {
+                                       String str = JcrxApi.getXmlValue(first);
+                                       if (str != null && str.trim().equals("")) {
+                                               node.remove();
+                                               return true;
+                                       }
+                               } else {
+                                       return false;
                                }
                        }
                        return false;