dion        2004/08/01 05:33:48

  Modified:    html2xdoc/src/main/org/apache/maven/html2xdoc
                        Html2XdocBean.java
  Log:
  Fix bug on empty html body
  
  Revision  Changes    Path
  1.8       +17 -15    
maven-plugins/html2xdoc/src/main/org/apache/maven/html2xdoc/Html2XdocBean.java
  
  Index: Html2XdocBean.java
  ===================================================================
  RCS file: 
/home/cvs/maven-plugins/html2xdoc/src/main/org/apache/maven/html2xdoc/Html2XdocBean.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Html2XdocBean.java        28 Mar 2004 22:00:54 -0000      1.7
  +++ Html2XdocBean.java        1 Aug 2004 12:33:48 -0000       1.8
  @@ -34,8 +34,8 @@
    * 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 <a href="mailto:[EMAIL PROTECTED]">James Strachan</a>
    */
   public class Html2XdocBean {
  @@ -75,7 +75,7 @@
       /**
        * Converts the given HTML document into the corresponding XDoc format
        * of XML
  -     * 
  +     *
        * @param html the input html document
        * @return Document
        */
  @@ -100,9 +100,9 @@
   
       /**
        * 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 &lt;p&gt; element
  -     * 
  +     *
        * @param output the output destination
        * @param body the block of HTML markup to convert
        */
  @@ -140,10 +140,10 @@
       /**
        * Specifies whether the node is a text modifying construct that should be
        * passed as is to the resultant html. Such as an anchor '&lt;a&gt;'.
  -     * 
  +     *
        * @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 @@
       }
   
       /**
  -     * 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 @@
   
       /**
        * 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 @@
   
       /**
        * Determines the heading level of the node.
  -     * 
  +     *
        * @param node the node to check
        * @return the integer level of the heading
        */
  @@ -192,7 +192,7 @@
       /**
        * 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 @@
        * 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 @@
        * @return List
        */
       protected List getBodyContent(List content) {
  -        // lets turn <pre> into <source> and concatenate consective entries 
  +        // lets turn <pre> into <source> and concatenate consective entries
           Element lastPre = null;
           LinkedList list = new LinkedList();
           boolean lastWasElement = true;
  @@ -342,6 +342,8 @@
               }
           }
   
  +        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 @@
   
       /**
        * @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) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to