diff --git a/html2xdoc/src/main/org/apache/maven/html2xdoc/Html2XdocBean.java b/html2xdoc/src/main/org/apache/maven/html2xdoc/Html2XdocBean.java index f80fd19a..4911022f 100644 --- a/html2xdoc/src/main/org/apache/maven/html2xdoc/Html2XdocBean.java +++ b/html2xdoc/src/main/org/apache/maven/html2xdoc/Html2XdocBean.java @@ -34,8 +34,8 @@ import org.dom4j.Node; * A simple bean for converting a HTML document into an XDoc compliant XML * document. * This could be done via XSLT but is a little more complex than it might first - * appear so its done via Java code instead. - * + * appear so its done via Java code instead. + * * @author James Strachan */ public class Html2XdocBean { @@ -75,7 +75,7 @@ public class Html2XdocBean { /** * Converts the given HTML document into the corresponding XDoc format * of XML - * + * * @param html the input html document * @return Document */ @@ -100,9 +100,9 @@ public class Html2XdocBean { /** * Iterates thorugh the given body looking for h1, h2, h3 nodes and - * creating the associated section elements. Any text nodes + * creating the associated section elements. Any text nodes * contained inside the body are wrapped in a <p> element - * + * * @param output the output destination * @param body the block of HTML markup to convert */ @@ -140,10 +140,10 @@ public class Html2XdocBean { /** * Specifies whether the node is a text modifying construct that should be * passed as is to the resultant html. Such as an anchor '<a>'. - * + * * @param node the node to check * @return true if the node is used to modify the formatting of the - * text; otherwise, false + * text; otherwise, false */ protected boolean isTextFormatting(Node node) { // Ultimately this needs bold, italic, and so on @@ -151,9 +151,9 @@ public class Html2XdocBean { } /** - * Specifies whether the node is character data and should be passed as + * Specifies whether the node is character data and should be passed as * straight text to the resultant html. - * + * * @param node the node to check * @return true if the node is a text node; otherwise, false. */ @@ -164,7 +164,7 @@ public class Html2XdocBean { /** * Specifies whether the node is a heading node. - * + * * @param node the node to check * @return true if the given node is a heading element * (h1, h2, h3 etc); otherwise, false @@ -176,7 +176,7 @@ public class Html2XdocBean { /** * Determines the heading level of the node. - * + * * @param node the node to check * @return the integer level of the heading */ @@ -192,7 +192,7 @@ public class Html2XdocBean { /** * Creates a section or subsection as necessary based on the node * for the output document. - * + * * @param output the output document to attach the section * @param node the node to base making a section on */ @@ -233,7 +233,7 @@ public class Html2XdocBean { * Determines if a new section is needed which is based on whether * the node's a heading level and equal to or less than the current * section's heading level. - * + * * @param node the node to check * @return true if the current node's information means for a new * section; otherwise, false @@ -314,7 +314,7 @@ public class Html2XdocBean { * @return List */ protected List getBodyContent(List content) { - // lets turn
 into  and concatenate consective entries 
+        // lets turn 
 into  and concatenate consective entries
         Element lastPre = null;
         LinkedList list = new LinkedList();
         boolean lastWasElement = true;
@@ -342,6 +342,8 @@ public class Html2XdocBean {
             }
         }
 
+        if (list.size() == 0) return list;
+
         // now lets remove any whitespace text nodes at the beginning and end
         while (true) {
             Node node = (Node) list.getFirst();
@@ -376,7 +378,7 @@ public class Html2XdocBean {
 
     /**
      * @param node the node to check
-     * @return true if the given node is a whitespace text node 
+     * @return true if the given node is a whitespace text node
      */
     protected boolean isWhitespace(Node node) {
         if (node instanceof CharacterData) {
diff --git a/html2xdoc/xdocs/changes.xml b/html2xdoc/xdocs/changes.xml
index 9adac491..6b849cc8 100644
--- a/html2xdoc/xdocs/changes.xml
+++ b/html2xdoc/xdocs/changes.xml
@@ -25,6 +25,7 @@
   
   
     
+      Fix crash with an empty html body element.
     
     
       Fix issues with DOM classes and jdk1.3